MCPcopy
hub / github.com/colbymchenry/codegraph / fileUriToPath

Function fileUriToPath

src/mcp/session.ts:48–59  ·  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

46 * Windows drive letter paths.
47 */
48function fileUriToPath(uri: string): string {
49 try {
50 const url = new URL(uri);
51 let filePath = decodeURIComponent(url.pathname);
52 if (process.platform === 'win32' && /^\/[a-zA-Z]:/.test(filePath)) {
53 filePath = filePath.slice(1);
54 }
55 return path.resolve(filePath);
56 } catch {
57 return uri.replace(/^file:\/\/\/?/, '');
58 }
59}
60
61/** First usable filesystem path from a `roots/list` result, or null. */
62function firstRootPath(result: unknown): string | null {

Callers 2

firstRootPathFunction · 0.85
handleInitializeMethod · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected