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

Function fileUriToPath

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

153 * Windows drive letter paths.
154 */
155function fileUriToPath(uri: string): string {
156 try {
157 const url = new URL(uri);
158 let filePath = decodeURIComponent(url.pathname);
159 if (process.platform === 'win32' && /^\/[a-zA-Z]:/.test(filePath)) {
160 filePath = filePath.slice(1);
161 }
162 return path.resolve(filePath);
163 } catch {
164 return uri.replace(/^file:\/\/\/?/, '');
165 }
166}
167
168/** First usable filesystem path from a `roots/list` result, or null. */
169function firstRootPath(result: unknown): string | null {

Callers 2

firstRootPathFunction · 0.85
handleInitializeMethod · 0.85

Calls 1

resolveMethod · 0.65

Tested by

no test coverage detected