whatwg-url
whatwg-url copied to clipboard
Implement `URL.parse`
About 5 months ago in https://github.com/whatwg/url/commit/58acb06dccec3e95a33d842337e61d25195d4b1b, the static method URL.parse
was added to the spec.
Quoting from MDN:
The URL.parse() static method of the URL interface returns a newly created URL object representing the URL defined by the parameters. If the given base URL or the resulting URL are not parsable and valid URLs,
null
is returned. This is an alternative to using the URL() constructor to construct a URL within a try...catch block, or using canParse() to check the parameters and returningnull
if the method returnsfalse
.
It seems like a useful addition to the API and has been shipped so far by Chrome and Firefox, with pending experiments from Safari and Opera.