diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-06-26 20:29:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-26 08:29:34 -0400 |
commit | 175867ab763a96f591b65386f09a385b87b399ab (patch) | |
tree | a30527457f2a9d53c5700657fec5bbcf07b570bf /cli/tests/unit | |
parent | 70463bac7d0327027f4650e3b4ab810e76604e2b (diff) |
fix(cli): strings shouldn't be interpreted as file URLs (#6412)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/path_from_url_test.ts | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/cli/tests/unit/path_from_url_test.ts b/cli/tests/unit/path_from_url_test.ts index 41f2c47ea..d43245c06 100644 --- a/cli/tests/unit/path_from_url_test.ts +++ b/cli/tests/unit/path_from_url_test.ts @@ -6,20 +6,27 @@ const { pathFromURL } = Deno[Deno.internal]; unitTest( { ignore: Deno.build.os === "windows" }, function pathFromURLPosix(): void { - assertEquals(pathFromURL("file:///test/directory"), "/test/directory"); - assertEquals(pathFromURL("file:///space_ .txt"), "/space_ .txt"); - assertThrows(() => pathFromURL("file://host/test/directory")); - assertThrows(() => pathFromURL("https://deno.land/welcome.ts")); + assertEquals( + pathFromURL(new URL("file:///test/directory")), + "/test/directory" + ); + assertEquals(pathFromURL(new URL("file:///space_ .txt")), "/space_ .txt"); + assertThrows(() => pathFromURL(new URL("https://deno.land/welcome.ts"))); } ); unitTest( { ignore: Deno.build.os !== "windows" }, function pathFromURLWin32(): void { - assertEquals(pathFromURL("file:///c:/windows/test"), "c:\\windows\\test"); - assertEquals(pathFromURL("file:///c:/space_ .txt"), "c:\\space_ .txt"); - assertThrows(() => pathFromURL("file:///thing/test")); - assertThrows(() => pathFromURL("https://deno.land/welcome.ts")); + assertEquals( + pathFromURL(new URL("file:///c:/windows/test")), + "c:\\windows\\test" + ); + assertEquals( + pathFromURL(new URL("file:///c:/space_ .txt")), + "c:\\space_ .txt" + ); + assertThrows(() => pathFromURL(new URL("https://deno.land/welcome.ts"))); /* TODO(ry) Add tests for these situations * ampersand_&.tx file:///D:/weird_names/ampersand_&.txt * at_@.txt file:///D:/weird_names/at_@.txt |