summaryrefslogtreecommitdiff
path: root/op_crates/web
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2021-01-29 13:08:22 +0000
committerGitHub <noreply@github.com>2021-01-29 08:08:22 -0500
commitf3122442db70d16f4861f39edf32d89ac2530aa2 (patch)
treee60d30f4501e808075ddc3cf13b6764774dc9df5 /op_crates/web
parent98878bd81231a631c494b6767576097f945eb813 (diff)
fix(op_crates/web): Add customInspect for Location (#9290)
Diffstat (limited to 'op_crates/web')
-rw-r--r--op_crates/web/11_url.js36
-rw-r--r--op_crates/web/12_location.js42
2 files changed, 61 insertions, 17 deletions
diff --git a/op_crates/web/11_url.js b/op_crates/web/11_url.js
index e4d45854b..5723201b3 100644
--- a/op_crates/web/11_url.js
+++ b/op_crates/web/11_url.js
@@ -522,23 +522,25 @@
#searchParams = null;
[Symbol.for("Deno.customInspect")]() {
- const keys = [
- "href",
- "origin",
- "protocol",
- "username",
- "password",
- "host",
- "hostname",
- "port",
- "pathname",
- "hash",
- "search",
- ];
- const objectString = keys
- .map((key) => `${key}: "${this[key] || ""}"`)
- .join(", ");
- return `URL { ${objectString} }`;
+ const object = {
+ href: this.href,
+ origin: this.origin,
+ protocol: this.protocol,
+ username: this.username,
+ password: this.password,
+ host: this.host,
+ hostname: this.hostname,
+ port: this.port,
+ pathname: this.pathname,
+ hash: this.hash,
+ search: this.search,
+ };
+ if (typeof globalThis?.Deno?.inspect == "function") {
+ return `URL ${Deno.inspect(object)}`;
+ }
+ return `URL { ${
+ Object.entries(object).map(([k, v]) => `${k}: ${v}`).join(", ")
+ } }`;
}
#updateSearchParams = () => {
diff --git a/op_crates/web/12_location.js b/op_crates/web/12_location.js
index d6a132413..f2409e82a 100644
--- a/op_crates/web/12_location.js
+++ b/op_crates/web/12_location.js
@@ -164,6 +164,27 @@
},
enumerable: true,
},
+ [Symbol.for("Deno.customInspect")]: {
+ value: function () {
+ const object = {
+ hash: this.hash,
+ host: this.host,
+ hostname: this.hostname,
+ href: this.href,
+ origin: this.origin,
+ pathname: this.pathname,
+ port: this.port,
+ protocol: this.protocol,
+ search: this.search,
+ };
+ if (typeof globalThis?.Deno?.inspect == "function") {
+ return `Location ${Deno.inspect(object)}`;
+ }
+ return `Location { ${
+ Object.entries(object).map(([k, v]) => `${k}: ${v}`).join(", ")
+ } }`;
+ },
+ },
});
}
}
@@ -305,6 +326,27 @@
value: "WorkerLocation",
configurable: true,
},
+ [Symbol.for("Deno.customInspect")]: {
+ value: function () {
+ const object = {
+ hash: this.hash,
+ host: this.host,
+ hostname: this.hostname,
+ href: this.href,
+ origin: this.origin,
+ pathname: this.pathname,
+ port: this.port,
+ protocol: this.protocol,
+ search: this.search,
+ };
+ if (typeof globalThis?.Deno?.inspect == "function") {
+ return `WorkerLocation ${Deno.inspect(object)}`;
+ }
+ return `WorkerLocation { ${
+ Object.entries(object).map(([k, v]) => `${k}: ${v}`).join(", ")
+ } }`;
+ },
+ },
});
let location = null;