Elide 1.0.0-alpha10 Help

URL API

Elide supports the WhatWG URL API Specification; this is the spec you use when you use the global URL class in JavaScript.

Elide's implementation of URL and URLSearchParams are based on JDK 22's URI, URL, and URLDecoder classes.

Classes

URL Parse and manipulate URLs

🟢 Supported.

URLSearchParams Parse and manipulate URL params

🟢 Supported.

URL

const url = new URL('https://google.com/search') url.pathname // returns '/search' url.hostname // returns 'google.com'

The URL class is used as a value class which wraps a standard Uniform Resource Locator, also known as a "URL". URLs have a specific structure and suite of supported components, as opposed to their more general ancestor, URIs.

URLs are strictly validated: when you construct one from a string, it is parsed eagerly, and you will get an error if the provided string is not a valid URL.

URLs, by spec, support the following components:

URL Property

Sample Value

Description

protocol

'https:'

The transport technology in use, including the trailing :; usually http: or https:

origin

'https://google.com:443'

The web origin value of the URL; consists of the scheme, domain, and port

host

'google.com:443'

The full host string, like https://google.com:443 from the example above

hostname

'google.com'

Just the hostname, like google.com from the sample above

port

443

Just the port, like 443 from the sample above (HTTPS)

pathname

/search

The path portion of the url /like-this/here, or / at a minimum

hash

#hello

The portion of the URL after #, if present

href

'https://google.com/search'

Formatted string version of the whole URL

username

'user'

If there is auth information in the URL (like user:pass@...), this is user

password

'pass'

password: If there is auth information in the URL (like user:pass@...), this is pass

search

'?hello=hi'

The portion of the URL after ? but before #, if present, including the initial ?

searchParams

URLSearchParams object

Parsed search value into a multimap of key-value pairs

URLSearchParams

Coming soon.

Last modified: 24 June 2024