File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1847,7 +1847,15 @@ A `URIError` is thrown if the `auth` property is present but cannot be decoded.
18471847strings . It is prone to security issues such as [host name spoofing][]
18481848and incorrect handling of usernames and passwords . Do not use with untrusted
18491849input . CVEs are not issued for ` url.parse()` vulnerabilities . Use the
1850- [WHATWG URL ][] API instead.
1850+ [WHATWG URL ][] API instead, for example:
1851+
1852+ ` ` ` js
1853+ function getURL(req) {
1854+ const proto = req.headers['x-forwarded-proto'] || 'https';
1855+ const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
1856+ return new URL(req.url || '/', ` ${proto}: // ${host}`);
1857+ }
1858+ ` ` `
18511859
18521860### ` url .resolve (from, to)`
18531861
You can’t perform that action at this time.
0 commit comments