diff options
Diffstat (limited to 'std/path/from_file_url_test.ts')
-rw-r--r-- | std/path/from_file_url_test.ts | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/std/path/from_file_url_test.ts b/std/path/from_file_url_test.ts index 8bbc4e986..7a0432f68 100644 --- a/std/path/from_file_url_test.ts +++ b/std/path/from_file_url_test.ts @@ -7,14 +7,13 @@ Deno.test("[path] fromFileUrl", function () { assertEquals(posix.fromFileUrl("file:///home/foo"), "/home/foo"); assertEquals(posix.fromFileUrl("https://example.com/foo"), "/foo"); assertEquals(posix.fromFileUrl("file:///"), "/"); - // FIXME(nayeemrmn): Remove the condition. UNC paths are supported here when - // run on Windows (matching the underlying URL class), but - // `posix.fromFileUrl()` should not support them under any circumstance. - if (Deno.build.os != "windows") { - assertEquals(posix.fromFileUrl("file:////"), "//"); - assertEquals(posix.fromFileUrl("file:////server"), "//server"); - assertEquals(posix.fromFileUrl("file:////server/file"), "//server/file"); - } + // Drive letters are supported platform-independently to align with the WHATWG + // URL specification. + assertEquals(posix.fromFileUrl("file:///c:"), "c:/"); + assertEquals(posix.fromFileUrl("file:///c:/"), "c:/"); + assertEquals(posix.fromFileUrl("file:///C:/"), "C:/"); + assertEquals(posix.fromFileUrl("file:///C:/Users/"), "C:/Users/"); + assertEquals(posix.fromFileUrl("file:///C:foo/bar"), "/C:foo/bar"); }); Deno.test("[path] fromFileUrl (win32)", function () { @@ -22,18 +21,9 @@ Deno.test("[path] fromFileUrl (win32)", function () { assertEquals(win32.fromFileUrl("file:///home/foo"), "\\home\\foo"); assertEquals(win32.fromFileUrl("https://example.com/foo"), "\\foo"); assertEquals(win32.fromFileUrl("file:///"), "\\"); - // FIXME(nayeemrmn): Remove the condition. UNC paths are only supported here - // when run on Windows (matching the underlying URL class), but - // `win32.fromFileUrl()` should support them under every circumstance. - if (Deno.build.os == "windows") { - assertEquals(win32.fromFileUrl("file:////"), "\\"); - assertEquals(win32.fromFileUrl("file:////server"), "\\"); - assertEquals(win32.fromFileUrl("file:////server/file"), "\\file"); - } - assertEquals(win32.fromFileUrl("file:///c"), "\\c"); assertEquals(win32.fromFileUrl("file:///c:"), "c:\\"); assertEquals(win32.fromFileUrl("file:///c:/"), "c:\\"); assertEquals(win32.fromFileUrl("file:///C:/"), "C:\\"); assertEquals(win32.fromFileUrl("file:///C:/Users/"), "C:\\Users\\"); - assertEquals(win32.fromFileUrl("file:///C:cwd/another"), "\\C:cwd\\another"); + assertEquals(win32.fromFileUrl("file:///C:foo/bar"), "\\C:foo\\bar"); }); |