Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. URLPattern

URLPattern

Baseline 2025
Newly available

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 inWeb Workers.

TheURLPattern interface of theURL 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 overviewpage:URL Pattern API.

Constructor

URLPattern()

Returns a newURLPattern object based on the given pattern and base URL.

Instance properties

hashRead only

A string containing a pattern to match thehash partof a URL.

hasRegExpGroupsRead only

A boolean indicating whether or not any of theURLPattern components containregular expression capturing groups.

hostnameRead only

A string containing a pattern to match thehostnamepart of a URL.

passwordRead only

A string containing a pattern to match thepasswordpart of a URL.

pathnameRead only

A string containing a pattern to match thepathnamepart of a URL.

portRead only

A string containing a pattern to match theport partof a URL.

protocolRead only

A string containing a pattern to match theprotocolpart of a URL.

searchRead only

A string containing a pattern to match thesearch partof a URL.

usernameRead only

A string containing a pattern to match theusernamepart of a URL.

Instance methods

exec()

Returns an object with the matched parts of the URL ornull if the URLdoes not match.

test()

Returnstrue if the URL matches the given pattern,false otherwise.

Specifications

Specification
URL Pattern
# urlpattern

Browser compatibility

See also

  • A polyfill ofURLPattern is availableon GitHub
  • The pattern syntax used by URLPattern is similar to the syntax used bypath-to-regexp

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp