diff options
Diffstat (limited to 'ext/url')
-rw-r--r-- | ext/url/00_url.js | 36 | ||||
-rw-r--r-- | ext/url/01_urlpattern.js | 33 |
2 files changed, 42 insertions, 27 deletions
diff --git a/ext/url/00_url.js b/ext/url/00_url.js index ce366a27a..d0ec376d6 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -8,6 +8,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; const primordials = globalThis.__bootstrap.primordials; const { ArrayIsArray, @@ -17,6 +18,7 @@ const { ArrayPrototypeSort, ArrayPrototypeSplice, ObjectKeys, + ObjectPrototypeIsPrototypeOf, SafeArrayIterator, StringPrototypeSlice, StringPrototypeStartsWith, @@ -410,20 +412,26 @@ class URL { } [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { - 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, - }; - return `${this.constructor.name} ${inspect(object, inspectOptions)}`; + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(URLPrototype, this), + keys: [ + "href", + "origin", + "protocol", + "username", + "password", + "host", + "hostname", + "port", + "pathname", + "hash", + "search", + ], + }), + inspectOptions, + ); } #updateSearchParams() { diff --git a/ext/url/01_urlpattern.js b/ext/url/01_urlpattern.js index 0cabccc1b..71962d405 100644 --- a/ext/url/01_urlpattern.js +++ b/ext/url/01_urlpattern.js @@ -10,11 +10,13 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypePop, RegExpPrototypeExec, RegExpPrototypeTest, + ObjectPrototypeIsPrototypeOf, SafeRegExp, Symbol, SymbolFor, @@ -222,19 +224,24 @@ class URLPattern { return result; } - [SymbolFor("Deno.customInspect")](inspect) { - return `URLPattern ${ - inspect({ - protocol: this.protocol, - username: this.username, - password: this.password, - hostname: this.hostname, - port: this.port, - pathname: this.pathname, - search: this.search, - hash: this.hash, - }) - }`; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + return inspect( + createFilteredInspectProxy({ + object: this, + evaluate: ObjectPrototypeIsPrototypeOf(URLPatternPrototype, this), + keys: [ + "protocol", + "username", + "password", + "hostname", + "port", + "pathname", + "search", + "hash", + ], + }), + inspectOptions, + ); } } |