MCPcopy
hub / github.com/coder/mux / basename

Method basename

src/common/utils/paths.ts:56–68  ·  view source on GitHub ↗

* Extract basename from path (OS-aware) * * @param filePath - Path to extract basename from * @returns The final component of the path * * @example * // Unix * basename("/home/user/project") // => "project" * * // Windows * basename("C:\\Users\\user\\project") // => "pr

(filePath: string)

Source from the content-addressed store, hash-verified

54 * basename("C:\\Users\\user\\project") // => "project"
55 */
56 static basename(filePath: string): string {
57 if (!filePath || typeof filePath !== "string") {
58 return filePath;
59 }
60
61 const lastSlash = isWindowsPlatform()
62 ? Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"))
63 : filePath.lastIndexOf("/");
64 if (lastSlash === -1) {
65 return filePath;
66 }
67 return filePath.slice(lastSlash + 1);
68 }
69
70 /**
71 * Split path into components (OS-aware)

Callers 12

getProjectNameMethod · 0.95
manualChunksFunction · 0.45
isWslLauncherFunction · 0.45
findMainRepoDirFunction · 0.45
mainFunction · 0.45
createWorkflowContextFunction · 0.45
listWorkspacesCommandFunction · 0.45
getProjectRouteIdFunction · 0.45
draft.test.tsFile · 0.45
openFirstWorkspaceFunction · 0.45
writePerfArtifactsFunction · 0.45
create.test.tsFile · 0.45

Calls 1

isWindowsPlatformFunction · 0.70

Tested by

no test coverage detected