(uri: string | null | undefined)
| 1319 | } |
| 1320 | |
| 1321 | function 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 | |
| 1345 | function contentUriToFileUri(uri: string): string | null { |
| 1346 | try { |
no test coverage detected