Skip to content

Commit 1d961fa

Browse files
anonrigmarco-ippolito
authored andcommitted
url: add missing documentation for URL.parse()
PR-URL: #53733 Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5ec5e78 commit 1d961fa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/api/url.md

+17
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,23 @@ const isValid = URL.canParse('/foo', 'https://example.org/'); // true
687687
const isNotValid = URL.canParse('/foo'); // false
688688
```
689689

690+
#### `URL.parse(input[, base])`
691+
692+
<!-- YAML
693+
added: v22.1.0
694+
-->
695+
696+
* `input` {string} The absolute or relative input URL to parse. If `input`
697+
is relative, then `base` is required. If `input` is absolute, the `base`
698+
is ignored. If `input` is not a string, it is [converted to a string][] first.
699+
* `base` {string} The base URL to resolve against if the `input` is not
700+
absolute. If `base` is not a string, it is [converted to a string][] first.
701+
* Returns: {URL|null}
702+
703+
Parses a string as a URL. If `base` is provided, it will be used as the base
704+
URL for the purpose of resolving non-absolute `input` URLs. Returns `null`
705+
if `input` is not a valid.
706+
690707
### Class: `URLSearchParams`
691708

692709
<!-- YAML

0 commit comments

Comments
 (0)