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

Method basename

src/node/utils/paths.main.ts:51–63  ·  view source on GitHub ↗

* Extract basename from path (OS-aware)

(filePath: string)

Source from the content-addressed store, hash-verified

49 * Extract basename from path (OS-aware)
50 */
51 static basename(filePath: string): string {
52 if (!filePath || typeof filePath !== "string") {
53 return filePath;
54 }
55
56 const lastSlash = isWindowsPlatform()
57 ? Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"))
58 : filePath.lastIndexOf("/");
59 if (lastSlash === -1) {
60 return filePath;
61 }
62 return filePath.slice(lastSlash + 1);
63 }
64
65 /**
66 * Split path into components (OS-aware)

Callers 15

getProjectNameMethod · 0.95
generateLegacyIdMethod · 0.45
watchProvidersFileMethod · 0.45
paths.test.tsFile · 0.45
pathUtils.test.tsFile · 0.45
getFallbackFilenameFunction · 0.45
looksLikeWslShellFunction · 0.45
createSubagentMetadataFunction · 0.45
constructorMethod · 0.45

Calls 1

isWindowsPlatformFunction · 0.70

Tested by 5

createSubagentMetadataFunction · 0.36
getWorkspacePathMethod · 0.36
getWorkspacePathMethod · 0.36
createWorkspaceWorktreeFunction · 0.36
workspaceInfoFunction · 0.36