Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: clarify treatment of non-string argument to new URL()
Closes: #41653
  • Loading branch information
Trott committed Jan 23, 2022
commit bba1f4d3ee7f5ff8c2e7da7ea84c0a1d2be05239
5 changes: 3 additions & 2 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base is also USVString so perhaps this should be {string} rather than {string|URL} and also include the note about being converted to a string that is added on line 134 for input.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base is also USVString so perhaps this should be {string} rather than {string|URL} and also include the note about being converted to a string that is added on line 134 for input.

@TimothyGu @jasnell Sound OK to you?

absolute.

Expand Down Expand Up @@ -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
Expand Down