GeezerVison is showing github.com — url: suppress warnings from url.format/url.resolve inside node_modules · nodejs/node@deead95
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/url.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -132,7 +132,7 @@ const { |
132 | 132 | let urlParseWarned = false; |
133 | 133 |
|
134 | 134 | function urlParse(url, parseQueryString, slashesDenoteHost) { |
135 | | - if (!urlParseWarned && !isInsideNodeModules(2)) { |
| 135 | + if (!urlParseWarned && !isInsideNodeModules(4)) { |
136 | 136 | urlParseWarned = true; |
137 | 137 | process.emitWarning( |
138 | 138 | '`url.parse()` behavior is not standardized and prone to ' + |
|
Collapse file
Copy file name to clipboardExpand all lines: test/fixtures/node_modules/url-deprecations.js +5Lines changed: 5 additions & 0 deletions Collapse file
Copy file name to clipboard +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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
Copy file name to clipboardExpand all lines: test/parallel/test-url-parse-invalid-input.js -7Lines changed: 0 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -87,13 +87,6 @@ if (common.hasIntl) { |
87 | 87 | })); |
88 | 88 | }); |
89 | 89 |
|
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 | | - }); |
97 | 90 | badURLs.forEach((badURL) => { |
98 | 91 | assert.throws(() => url.parse(badURL), { |
99 | 92 | code: 'ERR_INVALID_ARG_VALUE', |
|