You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: types/node/url.d.ts
+32-8Lines changed: 32 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -71,20 +71,44 @@ declare module "url" {
71
71
* A `URIError` is thrown if the `auth` property is present but cannot be decoded.
72
72
*
73
73
* `url.parse()` uses a lenient, non-standard algorithm for parsing URL
74
-
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted
75
-
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead.
74
+
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487)
75
+
* and incorrect handling of usernames and passwords. Do not use with untrusted
76
+
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
77
+
* [WHATWG URL](https://nodejs.org/docs/latest-v24.x/api/url.html#the-whatwg-url-api) API instead, for example:
78
+
*
79
+
* ```js
80
+
* function getURL(req) {
81
+
* const proto = req.headers['x-forwarded-proto'] || 'https';
* return new URL(req.url || '/', `${proto}://${host}`);
84
+
* }
85
+
* ```
86
+
*
87
+
* The example above assumes well-formed headers are forwarded from a reverse
88
+
* proxy to your Node.js server. If you are not using a reverse proxy, you should
89
+
* use the example below:
90
+
*
91
+
* ```js
92
+
* function getURL(req) {
93
+
* return new URL(req.url || '/', 'https://example.com');
94
+
* }
95
+
* ```
76
96
* @since v0.1.25
77
97
* @deprecated Use the WHATWG URL API instead.
78
98
* @param urlString The URL string to parse.
79
-
* @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property
80
-
* on the returned URL object will be an unparsed, undecoded string.
81
-
* @param [slashesDenoteHost=false] If `true`, the first token after the literal string `//` and preceding the next `/` will be interpreted as the `host`. For instance, given `//foo/bar`, the
82
-
* result would be `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
99
+
* @param parseQueryString If `true`, the `query` property will always
100
+
* be set to an object returned by the [`querystring`](https://nodejs.org/docs/latest-v24.x/api/querystring.html) module's `parse()`
101
+
* method. If `false`, the `query` property on the returned URL object will be an
0 commit comments