Skip to content

Commit 0d329fc

Browse files
committed
url: runtime deprecate url.parse
1 parent 291d90a commit 0d329fc

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

doc/api/deprecations.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3441,6 +3441,10 @@ Node-API callbacks.
34413441

34423442
<!-- YAML
34433443
changes:
3444+
- version:
3445+
- REPLACEME
3446+
pr-url: https://github.com/nodejs/node/pull/55017
3447+
description: Runtime deprecation.
34443448
- version:
34453449
- v19.9.0
34463450
- v18.17.0
@@ -3453,7 +3457,7 @@ changes:
34533457
description: Documentation-only deprecation.
34543458
-->
34553459

3456-
Type: Documentation-only (supports [`--pending-deprecation`][])
3460+
Type: Runtime
34573461

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

lib/url.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const {
4545

4646
// This ensures setURLConstructor() is called before the native
4747
// URL::ToObject() method is used.
48-
const { spliceOne } = require('internal/util');
48+
const { spliceOne, deprecate } = require('internal/util');
4949

5050
// WHATWG URL implementation provided by internal/url
5151
const {
@@ -63,8 +63,6 @@ const {
6363

6464
const bindingUrl = internalBinding('url');
6565

66-
const { getOptionValue } = require('internal/options');
67-
6866
// Original url.parse() API
6967

7068
function Url() {
@@ -122,20 +120,7 @@ const {
122120
CHAR_COLON,
123121
} = require('internal/constants');
124122

125-
let urlParseWarned = false;
126-
127123
function urlParse(url, parseQueryString, slashesDenoteHost) {
128-
if (!urlParseWarned && getOptionValue('--pending-deprecation')) {
129-
urlParseWarned = true;
130-
process.emitWarning(
131-
'`url.parse()` behavior is not standardized and prone to ' +
132-
'errors that have security implications. Use the WHATWG URL API ' +
133-
'instead. CVEs are not issued for `url.parse()` vulnerabilities.',
134-
'DeprecationWarning',
135-
'DEP0169',
136-
);
137-
}
138-
139124
if (url instanceof Url) return url;
140125

141126
const urlObject = new Url();
@@ -1023,7 +1008,11 @@ function pathToFileURL(path, options) {
10231008
module.exports = {
10241009
// Original API
10251010
Url,
1026-
parse: urlParse,
1011+
parse: deprecate(
1012+
urlParse,
1013+
'url.parse() is deprecated and the behavior is prone to ' +
1014+
'errors that have security implications. Use new URL() instead.',
1015+
'DEP0169'),
10271016
resolve: urlResolve,
10281017
resolveObject: urlResolveObject,
10291018
format: urlFormat,

0 commit comments

Comments
 (0)