MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / fileUriToPath

Function fileUriToPath

src/mcp/session.ts:70–81  ·  view source on GitHub ↗

* Convert a file:// URI to a filesystem path. Handles URL encoding and * Windows drive letter paths.

(uri: string)

Source from the content-addressed store, hash-verified

68 * Windows drive letter paths.
69 */
70function fileUriToPath(uri: string): string {
71 try {
72 const url = new URL(uri);
73 let filePath = decodeURIComponent(url.pathname);
74 if (process.platform === 'win32' && /^\/[a-zA-Z]:/.test(filePath)) {
75 filePath = filePath.slice(1);
76 }
77 return path.resolve(filePath);
78 } catch {
79 return uri.replace(/^file:\/\/\/?/, '');
80 }
81}
82
83/** First usable filesystem path from a `roots/list` result, or null. */
84function firstRootPath(result: unknown): string | null {

Callers 2

firstRootPathFunction · 0.85
handleInitializeMethod · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected