MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / toWorkspaceRelative

Function toWorkspaceRelative

graph-ui/src/ir/file-uri.ts:54–66  ·  view source on GitHub ↗
(root: string, file: string | undefined)

Source from the content-addressed store, hash-verified

52 * is the exact fragility this function exists to remove.
53 */
54export function toWorkspaceRelative(root: string, file: string | undefined): string {
55 if (file === undefined || file.length === 0) {
56 return '';
57 }
58 const path = file.startsWith('file://')
59 ? file.slice('file://'.length).split('/').map(decodeSegment).join('/')
60 : file;
61 const normalizedRoot = root.replace(/\/+$/, '');
62 if (normalizedRoot.length > 0 && path.startsWith(`${normalizedRoot}/`)) {
63 return path.slice(normalizedRoot.length + 1);
64 }
65 return path;
66}
67
68/** A segment that is not valid percent-encoding is taken literally, never dropped. */
69function decodeSegment(segment: string): string {

Callers 3

workspacePathOfFunction · 0.90
testItemKeyFunction · 0.90
resolveCalleeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected