MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / normalizePath

Method normalizePath

src/utils/usage-tracker.ts:649–667  ·  view source on GitHub ↗

* Normalize a file path to be relative to root and use forward slashes

(filePath: string)

Source from the content-addressed store, hash-verified

647 * Normalize a file path to be relative to root and use forward slashes
648 */
649 private normalizePath(filePath: string): string {
650 // Convert backslashes to forward slashes
651 let normalized = filePath.replace(/\\/g, '/');
652
653 // Make relative to root if absolute
654 if (normalized.startsWith(this.rootPath)) {
655 normalized = normalized.slice(this.rootPath.length);
656 if (normalized.startsWith('/')) {
657 normalized = normalized.slice(1);
658 }
659 }
660
661 // Remove leading ./ if present
662 if (normalized.startsWith('./')) {
663 normalized = normalized.slice(2);
664 }
665
666 return normalized;
667 }
668
669 /**
670 * Track that importingFile imports importedFile

Callers 2

trackImportMethod · 0.95
trackExportsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected