diff options
Diffstat (limited to 'op_crates/web/11_url.js')
-rw-r--r-- | op_crates/web/11_url.js | 36 |
1 files changed, 19 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 = () => { |