MCPcopy Create free account
hub / github.com/GCWing/BitFun / dirnameAbsolutePath

Function dirnameAbsolutePath

src/web-ui/src/shared/utils/pathUtils.ts:105–111  ·  view source on GitHub ↗
(fullPath: string)

Source from the content-addressed store, hash-verified

103
104/** Parent directory; supports mixed separators and Unix root (`/` parent of `/foo`). */
105export function dirnameAbsolutePath(fullPath: string): string {
106 if (!fullPath || typeof fullPath !== 'string') return '';
107 const i = Math.max(fullPath.lastIndexOf('/'), fullPath.lastIndexOf('\\'));
108 if (i < 0) return '';
109 if (i === 0) return fullPath[0] === '/' ? '/' : '';
110 return fullPath.slice(0, i);
111}
112
113/** Replace the final segment; keeps the separator style before the basename. */
114export function replaceBasename(fullPath: string, newName: string): string {

Callers 6

handleFileChangeMethod · 0.90
PlanViewerFunction · 0.90
getParentDirectoryMethod · 0.90
PlanDisplayFunction · 0.90

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected