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

Function normalizeRootUriForServer

src/cm/lsp/clientManager.ts:1292–1319  ·  view source on GitHub ↗
(
  _server: LspServerDefinition,
  rootUri: string | null,
)

Source from the content-addressed store, hash-verified

1290export default defaultManager;
1291
1292function normalizeRootUriForServer(
1293 _server: LspServerDefinition,
1294 rootUri: string | null,
1295): NormalizedRootUri {
1296 if (!rootUri || typeof rootUri !== "string") {
1297 return { normalizedRootUri: null, originalRootUri: null };
1298 }
1299 const schemeMatch = /^([a-zA-Z][\w+\-.]*?):/.exec(rootUri);
1300 const scheme = schemeMatch ? schemeMatch[1].toLowerCase() : null;
1301
1302 // Already a file:// URI - use as-is
1303 if (scheme === "file") {
1304 return { normalizedRootUri: rootUri, originalRootUri: rootUri };
1305 }
1306
1307 // Try to convert content:// URIs to file:// URIs
1308 if (scheme === "content") {
1309 const fileUri = contentUriToFileUri(rootUri);
1310 if (fileUri) {
1311 return { normalizedRootUri: fileUri, originalRootUri: rootUri };
1312 }
1313 // Can't convert to file:// - server won't work properly
1314 return { normalizedRootUri: null, originalRootUri: rootUri };
1315 }
1316
1317 // Unknown scheme - try to use as-is
1318 return { normalizedRootUri: rootUri, originalRootUri: rootUri };
1319}
1320
1321function normalizeDocumentUri(uri: string | null | undefined): string | null {
1322 if (!uri || typeof uri !== "string") return null;

Callers 1

#resolveRuntimeTargetMethod · 0.85

Calls 2

contentUriToFileUriFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected