diff --git a/doc/api/url.md b/doc/api/url.md index 8bde8f1161ca70..bdb544a95b9bec 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -1853,7 +1853,7 @@ input. CVEs are not issued for `url.parse()` vulnerabilities. Use the 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}`); + return new URL(`${proto}://${host}${req.url || '/'}`); } ``` @@ -1863,7 +1863,7 @@ use the example below: ```js function getURL(req) { - return new URL(req.url || '/', 'https://example.com'); + return new URL(`https://example.com${req.url || '/'}`); } ```