summaryrefslogtreecommitdiff
path: root/std/path/from_file_url_test.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-06-26 13:34:17 +0100
committerGitHub <noreply@github.com>2020-06-26 08:34:17 -0400
commited0b1d462718166143b67056c36c7db15cc736d7 (patch)
tree9151555dc8fe7e547e415a185e25a13de11c7b98 /std/path/from_file_url_test.ts
parent175867ab763a96f591b65386f09a385b87b399ab (diff)
fix(cli/js/web/url): Support UNC paths on Windows (#6418)
Diffstat (limited to 'std/path/from_file_url_test.ts')
-rw-r--r--std/path/from_file_url_test.ts60
1 files changed, 31 insertions, 29 deletions
diff --git a/std/path/from_file_url_test.ts b/std/path/from_file_url_test.ts
index b3f2bb6c6..8bbc4e986 100644
--- a/std/path/from_file_url_test.ts
+++ b/std/path/from_file_url_test.ts
@@ -1,37 +1,39 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import * as path from "./mod.ts";
+import { posix, win32 } from "./mod.ts";
import { assertEquals } from "../testing/asserts.ts";
Deno.test("[path] fromFileUrl", function () {
- assertEquals(
- path.posix.fromFileUrl(new URL("file:///home/foo")),
- "/home/foo"
- );
- assertEquals(path.posix.fromFileUrl("file:///home/foo"), "/home/foo");
- assertEquals(path.posix.fromFileUrl("https://example.com/foo"), "/foo");
- assertEquals(path.posix.fromFileUrl("file:///"), "/");
+ assertEquals(posix.fromFileUrl(new URL("file:///home/foo")), "/home/foo");
+ 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");
+ }
});
Deno.test("[path] fromFileUrl (win32)", function () {
- assertEquals(
- path.win32.fromFileUrl(new URL("file:///home/foo")),
- "\\home\\foo"
- );
- assertEquals(path.win32.fromFileUrl("file:///home/foo"), "\\home\\foo");
- assertEquals(path.win32.fromFileUrl("https://example.com/foo"), "\\foo");
- assertEquals(path.win32.fromFileUrl("file:///"), "\\");
- // FIXME(nayeemrmn): Support UNC paths. Needs support in the underlying URL
- // built-in like Chrome has.
- // assertEquals(path.win32.fromFileUrl("file:////"), "\\");
- // 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:/Users/"), "C:\\Users\\");
- assertEquals(
- path.win32.fromFileUrl("file:///C:cwd/another"),
- "\\C:cwd\\another"
- );
+ assertEquals(win32.fromFileUrl(new URL("file:///home/foo")), "\\home\\foo");
+ 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");
});