summaryrefslogtreecommitdiff
path: root/cli/js
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 /cli/js
parent175867ab763a96f591b65386f09a385b87b399ab (diff)
fix(cli/js/web/url): Support UNC paths on Windows (#6418)
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/web/url.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/cli/js/web/url.ts b/cli/js/web/url.ts
index 76aa21919..60690d46a 100644
--- a/cli/js/web/url.ts
+++ b/cli/js/web/url.ts
@@ -62,12 +62,15 @@ function parse(url: string, isBase = true): URLParts | undefined {
parts.password = "";
[parts.hostname, restUrl] = takePattern(restUrl, /^[/\\]{2}([^/\\?#]*)/);
parts.port = "";
+ if (build.os == "windows" && parts.hostname == "") {
+ // UNC paths. e.g. "\\\\localhost\\foo\\bar" on Windows should be
+ // representable as `new URL("file:////localhost/foo/bar")` which is
+ // equivalent to: `new URL("file://localhost/foo/bar")`.
+ [parts.hostname, restUrl] = takePattern(restUrl, /^[/\\]{2,}([^/\\?#]*)/);
+ }
} else if (specialSchemes.includes(parts.protocol)) {
let restAuthority;
- [restAuthority, restUrl] = takePattern(
- restUrl,
- /^[/\\]{2}[/\\]*([^/\\?#]+)/
- );
+ [restAuthority, restUrl] = takePattern(restUrl, /^[/\\]{2,}([^/\\?#]+)/);
if (isBase && restAuthority == "") {
return undefined;
}