Docs

URL.prototype.pathname

The path of the URL.

Example

let url = new URL("https://example.com/api/users?id=123")
url.pathname
"/api/users"
let url = new URL("https://example.com")
url.pathname = "/new/path"
url.href
"https://example.com/new/path"