| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern | [Back] [Original] |
Get to know MDN better
Since September 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Note: This feature is available in Web Workers.
The URLPattern interface of the URL Pattern API 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.
URLPattern()Returns a new URLPattern object based on the given pattern and base URL.
hash Read onlyA string containing a pattern to match the hash part of a URL.
hasRegExpGroups Read onlyA boolean indicating whether or not any of the URLPattern components contain regular expression capturing groups.
hostname Read onlyA string containing a pattern to match the hostname part of a URL.
password Read onlyA string containing a pattern to match the password part of a URL.
pathname Read onlyA string containing a pattern to match the pathname part of a URL.
port Read onlyA string containing a pattern to match the port part of a URL.
protocol Read onlyA string containing a pattern to match the protocol part of a URL.
search Read onlyA string containing a pattern to match the search part of a URL.
username Read onlyA 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.
| Specification |
|---|
| URL Pattern # urlpattern |
URLPattern is available
on GitHubThis page was last modified on Jul 3, 2025 by MDN contributors.
URLPatternYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |