# 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.

## Constructor

[URLPattern()](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern)
Returns a new URLPattern object based on the given pattern and base URL.

## Instance properties

[hash](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern)
A string containing a pattern to match the hash part of a URL.

[hostname](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/hostname)
A string containing a pattern to match the hostname part of a URL.

[password](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/password)
A string containing a pattern to match the password part of a URL.

[pathname](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/pathname)
A string containing a pattern to match the pathname part of a URL.

[port](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/port) 
A string containing a pattern to match the port part of a URL.

[protocol](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/protocol)
A string containing a pattern to match the protocol part of a URL.

[search](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/search) 
A string containing a pattern to match the search part of a URL.

[username](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/username)
A string containing a pattern to match the username part of a URL.

## Instance methods

[exec()](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/exec) 
Returns an object with the matched parts of the URL or null if the URL does not match.

[test()](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/test) 
Returns true if the URL matches the given pattern, false otherwise.

---

For more information on [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) visit MDN Web Docs.