url: add missing documentation for `URL.parse()`

PR-URL: https://github.com/nodejs/node/pull/53733
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
pull/53826/head
Yagiz Nizipli 2024-07-04 22:51:03 -04:00 committed by Antoine du Hamel
parent 3ab8aba478
commit 1300169f80
No known key found for this signature in database
GPG Key ID: 21D900FFDB233756
1 changed files with 17 additions and 0 deletions

View File

@ -691,6 +691,23 @@ const isValid = URL.canParse('/foo', 'https://example.org/'); // true
const isNotValid = URL.canParse('/foo'); // false
```
#### `URL.parse(input[, base])`
<!-- YAML
added: v22.1.0
-->
* `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} The base URL to resolve against if the `input` is not
absolute. If `base` is not a string, it is [converted to a string][] first.
* Returns: {URL|null}
Parses a string as a URL. If `base` is provided, it will be used as the base
URL for the purpose of resolving non-absolute `input` URLs. Returns `null`
if `input` is not a valid.
### Class: `URLSearchParams`
<!-- YAML