MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / dirname

Function dirname

src/utils/Path.js:9–17  ·  view source on GitHub ↗

* The path.dirname() method returns the directory name of a path, * similar to the Unix dirname command. * Trailing directory separators are ignored. * @param {string} path * @returns {string}

(path)

Source from the content-addressed store, hash-verified

7 * @returns {string}
8 */
9 dirname(path) {
10 if (path.endsWith("/")) path = path.slice(0, -1);
11 const parts = path.split("/").slice(0, -1);
12 if (!/^(\.|\.\.|)$/.test(parts[0])) parts.unshift(".");
13 const res = parts.join("/");
14
15 if (!res) return "/";
16 else return res;
17 },
18
19 /**
20 * The path.basename() methods returns the last portion of a path,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected