URLPattern

The URLPattern interface is used to match URLs or portions of URLs against a specified pattern. The pattern may contain capture groups that extract specific parts of the matched URL.

URLPattern() Returns a new URLPattern object based on the given pattern and base URL.

hash A string containing a pattern to match the hash part of a URL.

hostname A string containing a pattern to match the hostname part of a URL.

password A string containing a pattern to match the password part of a URL.

pathname A string containing a pattern to match the pathname part of a URL.

port A string containing a pattern to match the port part of a URL.

protocol A string containing a pattern to match the protocol part of a URL.

search A string containing a pattern to match the search part of a URL.

username A string containing a pattern to match the username part of a URL.

exec() Returns an object with the matched parts of the URL or null if the URL does not match.

test() Returns true if the URL matches the given pattern, false otherwise.


For more information on URLPattern visit MDN Web Docs.


Contributors