MCPcopy Create free account
hub / github.com/backnotprop/plannotator / extractDirName

Function extractDirName

packages/shared/project.ts:46–60  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

44 * Extract directory name from a path
45 */
46export function extractDirName(path: string): string | null {
47 if (!path || typeof path !== "string") return null;
48
49 const trimmed = path.trim().replace(/\/+$/, "");
50 if (trimmed === "" || trimmed === "/") return null;
51
52 const parts = trimmed.split("/");
53 const name = parts[parts.length - 1];
54
55 // Skip generic names
56 const skipNames = new Set(["home", "users", "user", "root", "tmp", "var"]);
57 if (skipNames.has(name.toLowerCase())) return null;
58
59 return sanitizeTag(name);
60}
61
62/**
63 * Extract hostname from a URL string, or return the original string on failure.

Callers 2

project.test.tsFile · 0.90
detectProjectNameFunction · 0.90

Calls 3

sanitizeTagFunction · 0.85
replaceMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected