URLPattern: pathname property

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 in Web Workers.

The pathname read-only property of the URLPattern interface is a string containing the pattern used to match the pathname part of a URL.

This is the normalized value of the pathname pattern passed to the constructor, an inherited value from a baseURL passed to the constructor, or the default value ("*"), which matches any path.

Value

A string.

Examples

Basic usage

The following example creates a URLPattern object with /books/:id(\\d) for the pathname part and logs the property. This pattern matches any URL that starts with /books/, followed by an integer.

js
const pattern = new URLPattern({ pathname: "/books/:id(\\d)" });
console.log(pattern.pathname); // "/books/:id(\\d)"
console.log(pattern.test("https://example.com/books/8")); // true

Specifications

Specification
URL Pattern
# dom-urlpattern-pathname

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
pathname
Chrome – Full support
Chrome 95 (Release date: 2021-10-19)
footnote Full support
Edge – Full support
Edge 95 (Release date: 2021-10-21)
footnote Full support
Firefox – Full support
Firefox 142 (Release date: 2025-08-19)
footnote Full support
Opera – Full support
Opera 81 (Release date: 2021-11-04)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 95 (Release date: 2021-10-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 142 (Release date: 2025-08-19)
footnote Full support
Opera Android – Full support
Opera Android 67 (Release date: 2022-01-31)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Full support
Samsung Internet 17 (Release date: 2022-05-04)
footnote Full support
WebView Android – Full support
WebView Android 95 (Release date: 2021-10-19)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support
Bun – Full support
Bun 1.3.4 (Release date: 2025-12-07)
footnote Full support
Deno – Full support
Deno 1.15 (Release date: 2021-10-12)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support