Sitelet https://github.com/nodejs/node/commit/6a4359a0b5
Skip to content

Commit 6a4359a

Browse 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 ad06bee commit 6a4359a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎doc/api/url.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
17201720
function geturl(/sitelet?url=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fcommit%2Freq) {
17211721
const proto = req.headers['x-forwarded-proto'] || 'https';
17221722
const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
1723-
return new url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fcommit%2F%253Cspan%2520class%3D%2522x%2520x-first%2520x-last%2522%253Ereq.url%2520%7C%7C%2520%27%2F%27%2C%2520%253C%2Fspan%253E%253Cspan%2520class%3D%2522pl-pds%2522%253E%2560%253C%2Fspan%253E%253C%2Fspan%253E%24%257Bproto%257D%253Cspan%2520class%3D%2522pl-k%2522%253E%3A%253C%2Fspan%253E%253Cspan%2520class%3D%2522pl-c%2522%253E%253Cspan%2520class%3D%2522pl-c%2522%253E%2F%2F%253C%2Fspan%253E%24%257Bhost%257D%2560);
1723+
return new url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fcommit%2F%253Cspan%2520class%3D%2522pl-pds%2522%253E%2560%253C%2Fspan%253E%253C%2Fspan%253E%24%257Bproto%257D%253Cspan%2520class%3D%2522pl-k%2522%253E%3A%253C%2Fspan%253E%253Cspan%2520class%3D%2522pl-c%2522%253E%253Cspan%2520class%3D%2522pl-c%2522%253E%2F%2F%253C%2Fspan%253E%24%257Bhost%253Cspan%2520class%3D%2522x%2520x-first%2520x-last%2522%253E%257D%24%257Breq.url%2520%7C%7C%2520%27%2F%27%253C%2Fspan%253E%257D%2560);
17241724
}
17251725
```
17261726
@@ -1730,7 +1730,7 @@ use the example below:
17301730
17311731
```js
17321732
function getURL(req) {
1733-
return new URL(req.url || '/', 'https://example.com');
1733+
return new URL(`https://example.com${req.url || '/'}`);
17341734
}
17351735
```
17361736

0 commit comments

Comments
 (0)