URL.pathname

The pathname property of the URL interface is a USVString containing an initial '/' followed by the path of the URL not including the query string or fragment (or the empty string if there is no path).

Note: This feature is available in Web Workers

Value

A USVString.

Examples

const url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname?q=value');
console.log(url.pathname); // Logs "/en-US/docs/Web/API/URL/pathname"

Specifications

Specification
URL Standard
# dom-url-pathname

Browser compatibility

BCD tables only load in the browser

See also

  • The URL interface it belongs to.