URL is a global and follows the URL Standard, including URL.parse() and
URL.canParse().
Example
// weburl.mjs
const url = new URL("../docs?page=2#intro", "https://elide.dev/guide/start");
console.log(url.href);
console.log(url.pathname, url.searchParams.get("page"), url.hash);
url.searchParams.append("tag", "node");
url.searchParams.sort();
console.log(url.search);
console.log(URL.canParse("not a url"), URL.parse("http://[::1]:8080/")?.host);
elide run weburl.mjs prints:
https://elide.dev/docs?page=2#intro
/docs 2 #intro
?page=2&tag=node
false [::1]:8080
URLSearchParams
URLSearchParams is a global and follows the same standard. url.searchParams returns the same live object on every
access.
Reference
Status: Full · 8,682 of 9,046 suite tests pass (96.0%) · since 1.1.0
Exports
| Export | Kind | Status | Notes |
|---|---|---|---|
URL | class | Full | URL.parse(), URL.canParse(), href, origin, protocol, username, password, host, hostname, port, pathname, search, searchParams, hash, toJSON() |
URLSearchParams | class | Full | size, append(), delete(), get(), getAll(), has(), set(), sort(), iteration |
Tests: wpt-wintertc url: 8,682 pass, 364 fail, 0 error, 2,251 skipped. Failing: url/toascii.window.js (298), url/IdnaTestV2.any.js (30), url/url-constructor.any.js (12), url/url-setters.any.js (12), url/urlsearchparams-constructor.any.js (6), url/urlencoded-parser.any.js (2), url/idlharness.any.js, url/url-origin.any.js, and 2 more.