MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / normalizeDocumentUri

Function normalizeDocumentUri

src/cm/lsp/clientManager.ts:1321–1343  ·  view source on GitHub ↗
(uri: string | null | undefined)

Source from the content-addressed store, hash-verified

1319}
1320
1321function normalizeDocumentUri(uri: string | null | undefined): string | null {
1322 if (!uri || typeof uri !== "string") return null;
1323
1324 const schemeMatch = /^([a-zA-Z][\w+\-.]*?):/.exec(uri);
1325 const scheme = schemeMatch ? schemeMatch[1].toLowerCase() : null;
1326
1327 // Already a file:// URI or untitled use as-is
1328 if (scheme === "file" || scheme === "untitled") {
1329 return uri;
1330 }
1331
1332 // Convert content:// URIs to file:// URIs
1333 if (scheme === "content") {
1334 const fileUri = contentUriToFileUri(uri);
1335 if (fileUri) {
1336 return fileUri;
1337 }
1338 return null;
1339 }
1340
1341 // Unknown scheme
1342 return uri;
1343}
1344
1345function contentUriToFileUri(uri: string): string | null {
1346 try {

Callers 1

#resolveDocumentUriMethod · 0.85

Calls 2

contentUriToFileUriFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected