MCPcopy Index your code
hub / github.com/microsoft/vscode-languageserver-node / uriToFilePath

Function uriToFilePath

server/src/files.ts:16–36  ·  view source on GitHub ↗
(uri: string)

Source from the content-addressed store, hash-verified

14 * complete implementation of handling VS Code URIs.
15 */
16export function uriToFilePath(uri: string): string | undefined {
17 let parsed = url.parse(uri);
18 if (parsed.protocol !== 'file:' || !parsed.path) {
19 return undefined;
20 }
21 let segments = parsed.path.split('/');
22 for (var i = 0, len = segments.length; i < len; i++) {
23 segments[i] = decodeURIComponent(segments[i]);
24 }
25 if (process.platform === 'win32' && segments.length > 1) {
26 let first = segments[0];
27 let second = segments[1];
28 // Do we have a drive letter and we started with a / which is the
29 // case if the first segement is empty (see split above)
30 if (first.length === 0 && second.length > 1 && second[1] === ':') {
31 // Remove first slash
32 segments.shift();
33 }
34 }
35 return path.normalize(segments.join('/'));
36}
37
38function isWindows(): boolean {
39 return process.platform === 'win32';

Callers

nothing calls this directly

Calls 1

shiftMethod · 0.80

Tested by

no test coverage detected