Urlpattern

URL Pattern Standard Options for constructing a URLPattern from individual component patterns.

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

Dictionary URLPatternInit

Options for constructing a URLPattern from individual component patterns.

Since: 1.1.0 Docs: WHATWG Docs

9 members: 9 undocumented

Properties

⚪ protocol
Options for constructing a URLPattern from individual component patterns.
⚪ username
Pattern for the protocol component (e.g. `"https"`).
⚪ password
Pattern for the username component.
⚪ hostname
Pattern for the password component.
⚪ port
Pattern for the hostname component (e.g. `"*.example.com"`).
⚪ pathname
Pattern for the port component (e.g. `"80"`).
⚪ search
Pattern for the pathname component (e.g. `"/users/:id"`).
⚪ hash
Pattern for the search/query component.
⚪ baseURL
A base URL string used to resolve relative patterns in the init.

---

Dictionary URLPatternOptions

Options controlling URLPattern behavior.

Since: 1.1.0 Docs: WHATWG Docs

1 members: 1 undocumented

Properties

⚪ ignoreCase
If true, pattern matching is case-insensitive.

---

Dictionary URLPatternComponentResult

The result of matching a single URL component against its pattern.

Since: 1.1.0 Docs: WHATWG Docs

2 members: 2 undocumented

Properties

⚪ input
The result of matching a single URL component against its pattern.
⚪ groups
An object whose keys are group names and values are the matched strings.

---

Dictionary URLPatternResult

The full result of executing a URLPattern against a URL.

Since: 1.1.0 Docs: WHATWG Docs

9 members: 9 undocumented

Properties

⚪ inputs
The input(s) that were passed to exec().
⚪ protocol
Options for constructing a URLPattern from individual component patterns.
⚪ username
Pattern for the protocol component (e.g. `"https"`).
⚪ password
Pattern for the username component.
⚪ hostname
Pattern for the password component.
⚪ port
Pattern for the hostname component (e.g. `"*.example.com"`).
⚪ pathname
Pattern for the port component (e.g. `"80"`).
⚪ search
Pattern for the pathname component (e.g. `"/users/:id"`).
⚪ hash
Pattern for the search/query component.

---

Interface URLPattern

Matches URLs against a pattern composed of per-component matchers.

Since: 1.1.0 Docs: WHATWG Docs

15 members: 15 undocumented

Constructors

⚪ constructor(input, baseURL, options)
Construct a URLPattern from a pattern string and optional base URL.
⚪ constructor(input, options)
Construct a URLPattern from a pattern string and optional base URL.

Methods

⚪ test(input, baseURL)
Test whether the given input matches this pattern.
⚪ test(input)
Test whether the given input matches this pattern.
⚪ exec(input, baseURL)
The full result of executing a URLPattern against a URL.
⚪ exec(input)
The full result of executing a URLPattern against a URL.

Properties

⚪ protocol
Options for constructing a URLPattern from individual component patterns.
⚪ username
Pattern for the protocol component (e.g. `"https"`).
⚪ password
Pattern for the username component.
⚪ hostname
Pattern for the password component.
⚪ port
Pattern for the hostname component (e.g. `"*.example.com"`).
⚪ pathname
Pattern for the port component (e.g. `"80"`).
⚪ search
Pattern for the pathname component (e.g. `"/users/:id"`).
⚪ hash
Pattern for the search/query component.
⚪ hasRegExpGroups
True if any component pattern uses regexp groups.

---

Details

constructor(input, baseURL, options)

new constructor(input: string, baseURL?: string, options?: URLPatternOptions)

new constructor(input: string, baseURL?: string, options?: URLPatternOptions)

Construct a URLPattern from a pattern string and optional base URL.
ParameterTypeDescription
inputstringA URL pattern string or an init dictionary specifying per-component patterns.
baseURL (optional)stringA base URL string used to resolve relative pattern strings.
options (optional)URLPatternOptionsOptions controlling pattern behavior.
Throws:
  • TypeError --- If the pattern string is relative and no baseURL is provided.

constructor(input, options)

new constructor(input: URLPatternInit, options?: URLPatternOptions)

new constructor(input: URLPatternInit, options?: URLPatternOptions)

Construct a URLPattern from a pattern string and optional base URL.
ParameterTypeDescription
inputURLPatternInitA URL pattern string or an init dictionary specifying per-component patterns.
options (optional)URLPatternOptionsOptions controlling pattern behavior.
Throws:
  • TypeError --- If the pattern string is relative and no baseURL is provided.

test(input, baseURL)

test(input?: string, baseURL?: string): boolean

test(input?: string, baseURL?: string): boolean

Test whether the given input matches this pattern.
ParameterTypeDescription
input (optional)stringA URL string or init dictionary to test against the pattern.
baseURL (optional)stringAn optional base URL for resolving relative input strings.
Returns: boolean True if the input matches the pattern. Throws:
  • TypeError --- If input is an init dictionary and baseURL is also provided.

test(input)

test(input: URLPatternInit): boolean

test(input: URLPatternInit): boolean

Test whether the given input matches this pattern.
ParameterTypeDescription
inputURLPatternInitA URL string or init dictionary to test against the pattern.
Returns: boolean True if the input matches the pattern. Throws:
  • TypeError --- If input is an init dictionary and baseURL is also provided.

---