url: runtime deprecate url.parse · nodejs/node@11fbdd8 · GitHub
Skip to content

Commit 11fbdd8

Browse files
authored
url: runtime deprecate url.parse
PR-URL: #55017 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c124cfb commit 11fbdd8

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

doc/api/deprecations.md

Lines changed: 5 additions & 1 deletion

lib/url.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const {
4646
// This ensures setURLConstructor() is called before the native
4747
// URL::ToObject() method is used.
4848
const { spliceOne } = require('internal/util');
49+
const { isInsideNodeModules } = internalBinding('util');
4950

5051
// WHATWG URL implementation provided by internal/url
5152
const {
@@ -63,8 +64,6 @@ const {
6364

6465
const bindingUrl = internalBinding('url');
6566

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

7069
function Url() {
@@ -125,7 +124,7 @@ const {
125124
let urlParseWarned = false;
126125

127126
function urlParse(url, parseQueryString, slashesDenoteHost) {
128-
if (!urlParseWarned && getOptionValue('--pending-deprecation')) {
127+
if (!urlParseWarned && !isInsideNodeModules(100, true)) {
129128
urlParseWarned = true;
130129
process.emitWarning(
131130
'`url.parse()` behavior is not standardized and prone to ' +

test/parallel/test-url-parse-invalid-input.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ if (common.hasIntl) {
9090
});
9191

9292
// Warning should only happen once per process.
93-
const expectedWarning = [
94-
`The URL ${badURLs[0]} is invalid. Future versions of Node.js will throw an error.`,
95-
'DEP0170',
96-
];
9793
common.expectWarning({
98-
DeprecationWarning: expectedWarning,
94+
DeprecationWarning: {
95+
// eslint-disable-next-line @stylistic/js/max-len
96+
DEP0169: '`url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.',
97+
DEP0170: `The URL ${badURLs[0]} is invalid. Future versions of Node.js will throw an error.`,
98+
},
9999
});
100100
badURLs.forEach((badURL) => {
101101
url.parse(badURL);

typings/internalBinding/util.d.ts

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)