@@ -687,6 +687,23 @@ const isValid = URL.canParse('/foo', 'https://example.org/'); // true
|
687 | 687 | const isNotValid = URL.canParse('/foo'); // false |
688 | 688 | ``` |
689 | 689 | |
| 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 | + |
690 | 707 | ### Class: `URLSearchParams` |
691 | 708 | |
692 | 709 | <!-- YAML |
|