summaryrefslogtreecommitdiff
path: root/cli/js/url.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/url.ts')
-rw-r--r--cli/js/url.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/cli/js/url.ts b/cli/js/url.ts
index 7b06fd64c..e5cf3ed62 100644
--- a/cli/js/url.ts
+++ b/cli/js/url.ts
@@ -17,7 +17,7 @@ interface URLParts {
}
const patterns = {
- protocol: "(?:([^:/?#]+):)",
+ protocol: "(?:([a-z]+):)",
authority: "(?://([^/?#]*))",
path: "([^?#]*)",
query: "(\\?[^#]*)",
@@ -228,10 +228,13 @@ export class URL {
this.username || this.password
? `${this.username}${this.password ? ":" + this.password : ""}@`
: "";
-
- return `${this.protocol}//${authentication}${this.host}${this.pathname}${
- this.search
- }${this.hash}`;
+ let slash = "";
+ if (this.host || this.protocol === "file:") {
+ slash = "//";
+ }
+ return `${this.protocol}${slash}${authentication}${this.host}${
+ this.pathname
+ }${this.search}${this.hash}`;
}
set href(value: string) {
@@ -244,7 +247,10 @@ export class URL {
}
get origin(): string {
- return `${this.protocol}//${this.host}`;
+ if (this.host) {
+ return `${this.protocol}//${this.host}`;
+ }
+ return "null";
}
get password(): string {