diff options
| author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-05-04 19:32:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-04 14:32:54 -0400 |
| commit | 8c509bd88517ebc92673d9da91e71a08868e830e (patch) | |
| tree | 5c880d6bafb1b5f22d69b3f1cfc52bbd4ea63056 /std | |
| parent | 6c02b061ce157b9fc3d20f9bcace0bc6638290d3 (diff) | |
feat(URL): Support drive letters for file URLs on Windows (#5074)
refactor: Parse URLs more sequentially. This makes it easier to change matching behaviour depending on the protocol.
fix: Fail when a host isn't given for certain protocols.
fix: Convert back-slashes info forward-slashes.
Diffstat (limited to 'std')
| -rw-r--r-- | std/path/from_file_url_test.ts | 2 | ||||
| -rw-r--r-- | std/path/win32.ts | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/std/path/from_file_url_test.ts b/std/path/from_file_url_test.ts index 79389b91b..b3f2bb6c6 100644 --- a/std/path/from_file_url_test.ts +++ b/std/path/from_file_url_test.ts @@ -26,7 +26,7 @@ Deno.test("[path] fromFileUrl (win32)", function () { // assertEquals(path.win32.fromFileUrl("file:////server"), "\\"); // assertEquals(path.win32.fromFileUrl("file:////server/file"), "\\file"); assertEquals(path.win32.fromFileUrl("file:///c"), "\\c"); - assertEquals(path.win32.fromFileUrl("file:///c:"), "\\c:"); + assertEquals(path.win32.fromFileUrl("file:///c:"), "c:\\"); assertEquals(path.win32.fromFileUrl("file:///c:/"), "c:\\"); assertEquals(path.win32.fromFileUrl("file:///C:/"), "C:\\"); assertEquals(path.win32.fromFileUrl("file:///C:/Users/"), "C:\\Users\\"); diff --git a/std/path/win32.ts b/std/path/win32.ts index 2c262b1b6..401e572db 100644 --- a/std/path/win32.ts +++ b/std/path/win32.ts @@ -909,6 +909,6 @@ export function parse(path: string): ParsedPath { */ export function fromFileUrl(url: string | URL): string { return new URL(url).pathname - .replace(/^\/(?=[A-Za-z]:\/)/, "") + .replace(/^\/*([A-Za-z]:)(\/|$)/, "$1/") .replace(/\//g, "\\"); } |
