MCPcopy
hub / github.com/livebud/bud / normalizePath

Function normalizePath

package/svelte/compiler.js:21956–21969  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

21954 return href.slice("https://foo.com/".length);
21955 }
21956 function normalizePath(input) {
21957 if (!parentRegex.test(input))
21958 return normalizeSimplePath(input);
21959 let total = 1;
21960 while (parentRegex.test(input))
21961 total++;
21962 const uniqDirectory = `z${uniqInStr(input)}/`;
21963 const search = new RegExp(`^(?:${uniqDirectory})*`);
21964 const relative = normalizeSimplePath(uniqDirectory.repeat(total) + input);
21965 return relative.replace(search, (all) => {
21966 const leftover = all.length / uniqDirectory.length;
21967 return "../".repeat(total - leftover);
21968 });
21969 }
21970 function resolve(input, base) {
21971 if (!base)
21972 base = "";

Callers 2

stripPathFilenameFunction · 0.85
resolveFunction · 0.85

Calls 3

normalizeSimplePathFunction · 0.85
uniqInStrFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected