Skip to content

Commit 30891b9

Browse files
committed
url: add pending-deprecation to url.parse()
1 parent f5eedf4 commit 30891b9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -3288,14 +3288,17 @@ Node-API callbacks.
32883288

32893289
<!-- YAML
32903290
changes:
3291+
- version: REPLACEME
3292+
pr-url: https://github.com/nodejs/node/pull/00000
3293+
description: Added support for `--pending-deprecation`.
32913294
- version:
32923295
- v19.0.0
32933296
- v18.13.0
32943297
pr-url: https://github.com/nodejs/node/pull/44919
32953298
description: Documentation-only deprecation.
32963299
-->
32973300

3298-
Type: Documentation-only
3301+
Type: Documentation-only (supports [`--pending-deprecation`][])
32993302

33003303
[`url.parse()`][] behavior is not standardized and prone to errors that
33013304
have security implications. Use the [WHATWG URL API][] instead. CVEs are not

lib/url.js

+12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const {
6262
formatUrl,
6363
} = internalBinding('url');
6464

65+
const { getOptionValue } = require('internal/options');
66+
6567
// Original url.parse() API
6668

6769
function Url() {
@@ -147,6 +149,16 @@ const {
147149
} = require('internal/constants');
148150

149151
function urlParse(url, parseQueryString, slashesDenoteHost) {
152+
if (getOptionValue('--pending-deprecation')){
153+
process.emitWarning(
154+
'`url.parse()` behavior is not standardized and prone to ' +
155+
'errors that have security implications. Use the WHATWG URL API ' +
156+
'instead. CVEs are not issued for `url.parse()` vulnerabilities.',
157+
'DeprecationWarning',
158+
'DEP0169',
159+
);
160+
}
161+
150162
if (url instanceof Url) return url;
151163

152164
const urlObject = new Url();

0 commit comments

Comments
 (0)