Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8357ebf

Browse filesBrowse files
Renegade334aduh95
authored andcommitted
url: suppress warnings from url.format/url.resolve inside node_modules
PR-URL: #62005 Fixes: #61724 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent d8ea1aa commit 8357ebf
Copy full SHA for 8357ebf

4 files changed

+29-9Lines changed: 29 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/url.js‎

Copy file name to clipboardExpand all lines: lib/url.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const {
131131
let urlParseWarned = false;
132132

133133
function urlParse(url, parseQueryString, slashesDenoteHost) {
134-
if (!urlParseWarned && !isInsideNodeModules(2)) {
134+
if (!urlParseWarned && !isInsideNodeModules(4)) {
135135
urlParseWarned = true;
136136
process.emitWarning(
137137
'`url.parse()` behavior is not standardized and prone to ' +
Collapse file

‎test/fixtures/node_modules/url-deprecations.js‎

Copy file name to clipboardExpand all lines: test/fixtures/node_modules/url-deprecations.js
+5Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const fixtures = require('../common/fixtures');
5+
6+
const assert = require('assert');
7+
const url = require('url');
8+
9+
const fixturePath = fixtures.path('node_modules', 'url-deprecations.js');
10+
11+
// Application deprecation for url.parse()
12+
url.parse('foo');
13+
common.expectWarning('DeprecationWarning',
14+
[/`url\.parse\(\)` behavior is not standardized/, 'DEP0169']);
15+
16+
// No warnings from inside node_modules
17+
common.spawnPromisified(process.execPath, [fixturePath]).then(
18+
common.mustCall(({ code, signal, stderr }) => {
19+
assert.strictEqual(code, 0);
20+
assert.strictEqual(signal, null);
21+
assert.doesNotMatch(stderr, /\[DEP0169\]/);
22+
})
23+
);
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-url-parse-invalid-input.js
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@ if (common.hasIntl) {
8989
}));
9090
});
9191

92-
// Warning should only happen once per process.
93-
common.expectWarning({
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-
},
99-
});
10092
badURLs.forEach((badURL) => {
10193
url.parse(badURL);
10294
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.