punycode: limit deprecation warning
DEP0040 is an extremely annoying warning. Most of the people seeing it cannot do anything about it. This commit updates the warning logic to only emit outside of node_modules. This is similar to other warnings such as the Buffer() constructor warning. Ideally, this should be backported to Node 22. Refs: https://github.com/nodejs/node/pull/47202 PR-URL: https://github.com/nodejs/node/pull/56632 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
6f946c95b9
commit
840f952268
@ -1,11 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
const {
|
||||||
|
isInsideNodeModules,
|
||||||
|
} = internalBinding('util');
|
||||||
|
|
||||||
process.emitWarning(
|
if (!isInsideNodeModules(100, true)) {
|
||||||
|
process.emitWarning(
|
||||||
'The `punycode` module is deprecated. Please use a userland ' +
|
'The `punycode` module is deprecated. Please use a userland ' +
|
||||||
'alternative instead.',
|
'alternative instead.',
|
||||||
'DeprecationWarning',
|
'DeprecationWarning',
|
||||||
'DEP0040',
|
'DEP0040',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/** Highest positive signed 32-bit float value */
|
/** Highest positive signed 32-bit float value */
|
||||||
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
node:punycode:49
|
node:punycode:54
|
||||||
throw new RangeError(errors[type]);
|
throw new RangeError(errors[type]);
|
||||||
^
|
^
|
||||||
|
|
||||||
RangeError: Invalid input
|
RangeError: Invalid input
|
||||||
at error (node:punycode:49:8)
|
at error (node:punycode:54:8)
|
||||||
at Object.decode (node:punycode:242:5)
|
at Object.decode (node:punycode:247:5)
|
||||||
at Object.<anonymous> (*core_line_numbers.js:13:10)
|
at Object.<anonymous> (*core_line_numbers.js:13:10)
|
||||||
|
|
||||||
Node.js *
|
Node.js *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user