Aller au contenu

Cette page n'est pas encore traduite. Elle s'affiche en anglais.

URL

How Elide supports the URL and URLSearchParams globals per the URL Standard, including URL.parse(), URL.canParse() and the live searchParams object.

Lire hors ligneelide help --lang fr api-whatwg-url

Sur cette page

URL is a global and follows the URL Standard, including URL.parse() and URL.canParse().

Example

js
// 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);
utf-8 · js · Lines: 9

elide run weburl.mjs prints:

text
https://elide.dev/docs?page=2#intro
/docs 2 #intro
?page=2&tag=node
false [::1]:8080
utf-8 · text · Lines: 4

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.

Cette page vous a-t-elle aidé ?