mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(url): properly indent when inspecting URLs (#14867)
This commit updates the custom inspect function for URL objects to pass the inspect options through so that the context is propagated and the resulting indentation is correct. Fixes: https://github.com/denoland/deno/issues/14171
This commit is contained in:
parent
eadf943e59
commit
b2109a12aa
4 changed files with 57 additions and 2 deletions
|
@ -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",
|
||||
});
|
||||
|
|
3
cli/tests/testdata/custom_inspect_url.js
vendored
Normal file
3
cli/tests/testdata/custom_inspect_url.js
vendored
Normal file
|
@ -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")] });
|
47
cli/tests/testdata/custom_inspect_url.js.out
vendored
Normal file
47
cli/tests/testdata/custom_inspect_url.js.out
vendored
Normal file
|
@ -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: ""
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue