Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: provide alternative to url.parse() using WHATWG URL
  • Loading branch information
styfle committed Sep 2, 2025
commit adead686a3257c498bdab5012a75425bcb3f2fd9
10 changes: 9 additions & 1 deletion doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,15 @@ A `URIError` is thrown if the `auth` property is present but cannot be decoded.
strings. It is prone to security issues such as [host name spoofing][]
and incorrect handling of usernames and passwords. Do not use with untrusted
input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
[WHATWG URL][] API instead.
[WHATWG URL][] API instead, for example:

```js
function getURL(req) {
const proto = req.headers['x-forwarded-proto'] || 'https';
const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
return new URL(req.url || '/', `${proto}://${host}`);
}
```

### `url.resolve(from, to)`

Expand Down
Loading