MCPcopy Create free account
hub / github.com/Snapchat/Valdi / fileUrlToAbsolutePath

Function fileUrlToAbsolutePath

valdi/vscode_debugger/src/common/urlUtils.ts:215–230  ·  view source on GitHub ↗
(urlOrPath: string)

Source from the content-addressed store, hash-verified

213export function fileUrlToAbsolutePath(urlOrPath: FileUrl): string;
214export function fileUrlToAbsolutePath(urlOrPath: string): string | undefined;
215export function fileUrlToAbsolutePath(urlOrPath: string): string | undefined {
216 if (!isFileUrl(urlOrPath)) {
217 return undefined;
218 }
219
220 urlOrPath = urlOrPath.replace('file:///', '');
221 urlOrPath = decodeURIComponent(urlOrPath);
222 if (urlOrPath[0] !== '/' && !urlOrPath.match(/^[A-Za-z]:/)) {
223 // If it has a : before the first /, assume it's a windows path or url.
224 // Ensure unix-style path starts with /, it can be removed when file:/// was stripped.
225 // Don't add if the url still has a protocol
226 urlOrPath = '/' + urlOrPath;
227 }
228
229 return fixDriveLetterAndSlashes(urlOrPath);
230}
231
232/**
233 * Converts a file URL to a windows network path, if possible.

Callers 7

urlUtils.test.tsFile · 0.90
shouldResolveSourceMapFunction · 0.90
parseSourceMapMethod · 0.90
_createPausedDetailsMethod · 0.90
fetchMethod · 0.90
urlToRegexFunction · 0.85
standardizeMatchFunction · 0.85

Calls 4

fixDriveLetterAndSlashesFunction · 0.90
isFileUrlFunction · 0.85
replaceMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected