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 deead95

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 83719ff commit deead95
Copy full SHA for deead95

4 files changed

+29-8Lines changed: 29 additions & 8 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
@@ -132,7 +132,7 @@ const {
132132
let urlParseWarned = false;
133133

134134
function urlParse(url, parseQueryString, slashesDenoteHost) {
135-
if (!urlParseWarned && !isInsideNodeModules(2)) {
135+
if (!urlParseWarned && !isInsideNodeModules(4)) {
136136
urlParseWarned = true;
137137
process.emitWarning(
138138
'`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
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ if (common.hasIntl) {
8787
}));
8888
});
8989

90-
// Warning should only happen once per process.
91-
common.expectWarning({
92-
DeprecationWarning: {
93-
// eslint-disable-next-line @stylistic/js/max-len
94-
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.',
95-
},
96-
});
9790
badURLs.forEach((badURL) => {
9891
assert.throws(() => url.parse(badURL), {
9992
code: 'ERR_INVALID_ARG_VALUE',

0 commit comments

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