Skip to main content
URL.prototype.pathname - node__url.d.ts - Node documentation
property URL.prototype.pathname

Usage in Deno

```typescript import { URL } from "node:node__url.d.ts"; ```
Gets and sets the path portion of the URL. ```js const myURL = new URL('https://example.org/abc/xyz?123'); console.log(myURL.pathname); // Prints /abc/xyz myURL.pathname = '/abcdef'; console.log(myURL.href); // Prints https://example.org/abcdef?123 ``` Invalid URL characters included in the value assigned to the `pathname` property are `percent-encoded`. The selection of which characters to percent-encode may vary somewhat from what the [parse](../.././node__url.d.ts/~/parse) and [format](../.././node__url.d.ts/~/format) methods would produce.

Type

string