diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index aed1fe0fec..2ba22d748c 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -2704,3 +2704,8 @@ itest!(error_name_non_string { output: "error_name_non_string.js.out", exit_code: 1, }); + +itest!(custom_inspect_url { + args: "run custom_inspect_url.js", + output: "custom_inspect_url.js.out", +}); diff --git a/cli/tests/testdata/custom_inspect_url.js b/cli/tests/testdata/custom_inspect_url.js new file mode 100644 index 0000000000..69aa2dc49c --- /dev/null +++ b/cli/tests/testdata/custom_inspect_url.js @@ -0,0 +1,3 @@ +console.log([new URL("https://example.com/path")]); +console.log({ url: new URL("https://example.com/path") }); +console.log({ url: [new URL("https://example.com/path")] }); diff --git a/cli/tests/testdata/custom_inspect_url.js.out b/cli/tests/testdata/custom_inspect_url.js.out new file mode 100644 index 0000000000..1c714e34e2 --- /dev/null +++ b/cli/tests/testdata/custom_inspect_url.js.out @@ -0,0 +1,47 @@ +[ + URL { + href: "https://example.com/path", + origin: "https://example.com", + protocol: "https:", + username: "", + password: "", + host: "example.com", + hostname: "example.com", + port: "", + pathname: "/path", + hash: "", + search: "" + } +] +{ + url: URL { + href: "https://example.com/path", + origin: "https://example.com", + protocol: "https:", + username: "", + password: "", + host: "example.com", + hostname: "example.com", + port: "", + pathname: "/path", + hash: "", + search: "" + } +} +{ + url: [ + URL { + href: "https://example.com/path", + origin: "https://example.com", + protocol: "https:", + username: "", + password: "", + host: "example.com", + hostname: "example.com", + port: "", + pathname: "/path", + hash: "", + search: "" + } + ] +} diff --git a/ext/url/00_url.js b/ext/url/00_url.js index ab34884552..3d81e5b9d9 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -322,7 +322,7 @@ this[_url] = opUrlParse(url, base); } - [SymbolFor("Deno.privateCustomInspect")](inspect) { + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { const object = { href: this.href, origin: this.origin, @@ -336,7 +336,7 @@ hash: this.hash, search: this.search, }; - return `${this.constructor.name} ${inspect(object)}`; + return `${this.constructor.name} ${inspect(object, inspectOptions)}`; } #updateSearchParams() {