URLPattern
The URLPattern interface matches URLs or parts of URLs against a pattern.
The pattern can contain capturing groups that extract parts of the matched URL.
More information about the syntax of patterns can be found on the API overview page: URL Pattern API
Note: This feature is available in Web Workers
Constructor
URLPattern()-
Returns a new
URLPatternobject based on the given pattern and base URL.
Properties
hash-
A
USVStringcontaining a pattern to match the hash part of a URL. hostname-
A
USVStringcontaining a pattern to match the hostname part of a URL. password-
A
USVStringcontaining a pattern to match the password part of a URL. pathname-
A
USVStringcontaining a pattern to match the pathname part of a URL. port-
A
USVStringcontaining a pattern to match the port part of a URL. protocol-
A
USVStringcontaining a pattern to match the protocol part of a URL. search-
A
USVStringcontaining a pattern to match the search part of a URL. username-
A
USVStringcontaining a pattern to match the username part of a URL.
Methods
Specifications
| Specification |
|---|
| URLPattern API # urlpattern |
Browser compatibility
BCD tables only load in the browser
See also
-
A polyfill of
URLPatternis available on GitHub - The pattern syntax used by URLPattern is similar to the syntax used by path-to-regexp