Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 70c2080

Browse filesBrowse files
styfleaduh95
authored andcommitted
doc: improve code snippet alternative of url.parse() using WHATWG URL
PR-URL: #60209 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent beadcf1 commit 70c2080
Copy full SHA for 70c2080

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/url.md‎

Copy file name to clipboardExpand all lines: doc/api/url.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
18471847
function getURL(req) {
18481848
const proto = req.headers['x-forwarded-proto'] || 'https';
18491849
const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
1850-
return new URL(req.url || '/', `${proto}://${host}`);
1850+
return new URL(`${proto}://${host}${req.url || '/'}`);
18511851
}
18521852
```
18531853
@@ -1857,7 +1857,7 @@ use the example below:
18571857
18581858
```js
18591859
function getURL(req) {
1860-
return new URL(req.url || '/', 'https://example.com');
1860+
return new URL(`https://example.com${req.url || '/'}`);
18611861
}
18621862
```
18631863

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.