MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / toRelativePath

Method toRelativePath

frontend/src/cache.ts:112–123  ·  view source on GitHub ↗

* Convert full path to relative path using workspace root. * Ensures consistent cache keys using relative paths for security and portability.

(filePath: string)

Source from the content-addressed store, hash-verified

110 * Ensures consistent cache keys using relative paths for security and portability.
111 */
112 private toRelativePath(filePath: string): string {
113 // Already relative (doesn't start with / or drive letter)
114 if (!filePath.startsWith('/') && !filePath.match(/^[A-Z]:\\/i)) {
115 return filePath;
116 }
117 // Convert absolute to relative
118 const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
119 if (workspaceRoot && filePath.startsWith(workspaceRoot)) {
120 return filePath.slice(workspaceRoot.length).replace(/^[/\\]/, '');
121 }
122 return filePath;
123 }
124
125 private async initializeCache() {
126 const workspaceFolders = vscode.workspace.workspaceFolders;

Callers 11

isFileValidMethod · 0.95
isFileCachedMethod · 0.95
getFileMethod · 0.95
debugFileStatusMethod · 0.95
checkFilesMethod · 0.95
setAnalysisResultMethod · 0.95
getMergedGraphMethod · 0.95
computeWorkflowsMethod · 0.95
invalidateFileMethod · 0.95
updateMetadataMethod · 0.95
pruneStaleEntriesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected