diff options
Diffstat (limited to 'std/path/posix.ts')
-rw-r--r-- | std/path/posix.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/std/path/posix.ts b/std/path/posix.ts index ba4cf7499..156aba796 100644 --- a/std/path/posix.ts +++ b/std/path/posix.ts @@ -421,3 +421,14 @@ export function parse(path: string): ParsedPath { return ret; } + +/** Converts a file URL to a path string. + * + * fromFileUrl("file:///home/foo"); // "/home/foo" + * + * Note that non-file URLs are treated as file URLs and irrelevant components + * are ignored. + */ +export function fromFileUrl(url: string | URL): string { + return new URL(url).pathname; +} |