MCPcopy
hub / github.com/codeaashu/claude-code / uriToFilePath

Function uriToFilePath

src/tools/LSPTool/LSPTool.ts:538–550  ·  view source on GitHub ↗

* Extracts a file path from a file:// URI, decoding percent-encoded characters.

(uri: string)

Source from the content-addressed store, hash-verified

536 * Extracts a file path from a file:// URI, decoding percent-encoded characters.
537 */
538function uriToFilePath(uri: string): string {
539 let filePath = uri.replace(/^file:\/\//, '')
540 // On Windows, file:///C:/path becomes /C:/path — strip the leading slash
541 if (/^\/[A-Za-z]:/.test(filePath)) {
542 filePath = filePath.slice(1)
543 }
544 try {
545 filePath = decodeURIComponent(filePath)
546 } catch {
547 // Use un-decoded path if malformed
548 }
549 return filePath
550}
551
552/**
553 * Filters out locations whose file paths are gitignored.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected