URL

Represents a parsed URL, providing read-write access to each component (protocol, host, pathname, search params, etc.) per the WHATWG URL Standard.

Module: whatwg.url Support: Experimental Since: 1.1.0 Docs: WHATWG Docs

Interface URL

Represents a parsed URL, providing read-write access to each component (protocol, host, pathname, search params, etc.) per the WHATWG URL Standard.

Since: 1.1.0 Docs: WHATWG Docs

16 members: 16 undocumented

Constructors

⚪ constructor(url, base)
string, string

Static Methods

⚪ parse(url, base)
→ URL?
⚪ canParse(url, base)
→ boolean

Methods

⚪ toJSON()
→ string

Properties

⚪ href
The full serialized URL. Setting throws TypeError if the value is not a valid URL.
⚪ origin
The full serialized URL. Setting throws TypeError if the value is not a valid URL.
⚪ protocol
The URL's scheme, including the trailing colon (e.g. `"https:"`).
⚪ username
The URL's scheme, including the trailing colon (e.g. `"https:"`).
⚪ password
The username component of the URL.
⚪ host
The password component of the URL.
⚪ hostname
The host, including port if non-default (e.g. `"example.com:8080"`).
⚪ port
The password component of the URL.
⚪ pathname
The path component of the URL, starting with `"/"`.
⚪ search
The query string including the leading `"?"`, or `""` if absent.
⚪ searchParams
A live URLSearchParams object backed by the URL's query string.
⚪ hash
The URL fragment including the leading `"#"`, or `""` if absent.

---

Details

constructor(url, base)

new constructor(url: string, base?: string) new constructor(url: string, base?: string)
ParameterTypeDescription
urlstringThe URL string to parse.
base (optional)stringOptional base URL to resolve relative URLs against.
Throws:
  • TypeError --- If url is not a valid URL and cannot be resolved against base.

---

Interface URLSearchParams

The query string including the leading "?", or "" if absent.

11 members: 11 undocumented

Constructors

⚪ constructor(init)
(sequence> or record or string)

Methods

⚪ append(name, value)
string, string
⚪ delete(name, value)
string, string
⚪ get(name)
→ string?
⚪ getAll(name)
→ sequence
⚪ has(name, value)
→ boolean
⚪ set(name, value)
string, string
⚪ sort()
Sorts all key/value pairs in place by key, in Unicode code unit order.

Properties

⚪ size
The number of key/value pairs contained in this object.

Stringifier

⚪ toString
→ string

Iterators

⚪ @@iterator
Not documented

---

Details

constructor(init)

new constructor(init?: (sequence> or record or string)) new constructor(init?: (sequence<sequence<string>> or record<string, string> or string))
ParameterTypeDescription
init (optional)(sequence<sequence<string>> or record<string, string> or string)
Throws:
  • TypeError --- If url is not a valid URL and cannot be resolved against base.

---