From bba1f4d3ee7f5ff8c2e7da7ea84c0a1d2be05239 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 22 Jan 2022 16:18:30 -0800 Subject: [PATCH 1/2] doc: clarify treatment of non-string argument to new URL() Closes: https://github.com/nodejs/node/issues/41653 --- doc/api/url.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index baed91eca5bcf9..37764a83e3128e 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -129,9 +129,9 @@ return `true`. #### `new URL(input[, base])` -* `input` {string} The absolute or relative input URL to parse. If `input` +* `input` {any} The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` - is ignored. + is ignored. If `input` is not a string, it is [converted to a string][] first. * `base` {string|URL} The base URL to resolve against if the `input` is not absolute. @@ -1701,6 +1701,7 @@ console.log(myURL.origin); [`url.toString()`]: #urltostring [`urlSearchParams.entries()`]: #urlsearchparamsentries [`urlSearchParams@@iterator()`]: #urlsearchparamssymboliterator +[converted to a string]: https://tc39.es/ecma262/#sec-tostring [examples of parsed URLs]: https://url.spec.whatwg.org/#example-url-parsing [host name spoofing]: https://hackerone.com/reports/678487 [legacy `urlObject`]: #legacy-urlobject From ff5b5a43846562544e8717b9e127df467a8f55e2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 22 Jan 2022 22:30:00 -0800 Subject: [PATCH 2/2] Update doc/api/url.md Co-authored-by: Timothy Gu --- doc/api/url.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/url.md b/doc/api/url.md index 37764a83e3128e..c8dfac649dc93c 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -129,7 +129,7 @@ return `true`. #### `new URL(input[, base])` -* `input` {any} The absolute or relative input URL to parse. If `input` +* `input` {string} The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is [converted to a string][] first. * `base` {string|URL} The base URL to resolve against if the `input` is not