MCPcopy Create free account
hub / github.com/Snapchat/Valdi / norm

Function norm

src/valdi_modules/src/valdi/file_system/web/FileSystem.ts:26–36  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

24
25const ROOT = "/";
26function norm(p: string): string {
27 // POSIX-like normalization; treat relative as from ROOT
28 const parts = (p.startsWith("/") ? p : ROOT + p).split("/").filter(Boolean);
29 const stack: string[] = [];
30 for (const part of parts) {
31 if (part === ".") continue;
32 if (part === "..") { stack.pop(); continue; }
33 stack.push(part);
34 }
35 return ROOT + stack.join("/");
36}
37function parentDir(p: string): string {
38 if (p === ROOT) return ROOT;
39 const idx = p.lastIndexOf("/");

Callers 4

removeSyncFunction · 0.85
createDirectorySyncFunction · 0.85
readFileSyncFunction · 0.85
writeFileSyncFunction · 0.85

Calls 6

filterMethod · 0.80
splitMethod · 0.80
startsWithMethod · 0.80
popMethod · 0.65
pushMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected