MCPcopy Create free account
hub / github.com/cloudflare/agents / normalizePath

Function normalizePath

packages/shell/src/workspace.ts:195–208  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

193}
194
195function normalizePath(path: string): string {
196 if (!path.startsWith("/")) path = "/" + path;
197 const parts = path.split("/");
198 const resolved: string[] = [];
199 for (const part of parts) {
200 if (part === "" || part === ".") continue;
201 if (part === "..") {
202 resolved.pop();
203 } else {
204 resolved.push(part);
205 }
206 }
207 return "/" + resolved.join("/");
208}
209
210function dirname(path: string): string {
211 const normalized = normalizePath(path);

Callers 3

realpathMethod · 0.70
resolvePathMethod · 0.70
dirnameFunction · 0.70

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected