Skip to content

Commit

Permalink
util: fix crashing when emitting new Buffer() deprecation warning nod…
Browse files Browse the repository at this point in the history
…ejs#53075

PR-URL: nodejs#53089
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
Uzlopak committed Jul 11, 2024
1 parent 9791836 commit 096e44a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const {
SafeWeakRef,
StringPrototypeIncludes,
StringPrototypeReplace,
StringPrototypeStartsWith,
StringPrototypeToLowerCase,
StringPrototypeToUpperCase,
Symbol,
Expand Down Expand Up @@ -515,11 +516,14 @@ function isInsideNodeModules() {
if (ArrayIsArray(stack)) {
for (const frame of stack) {
const filename = frame.getFileName();
// If a filename does not start with / or contain \,
// it's likely from Node.js core.

if (
filename[0] !== '/' &&
StringPrototypeIncludes(filename, '\\') === false
filename == null ||
StringPrototypeStartsWith(filename, 'node:') === true ||
(
filename[0] !== '/' &&
StringPrototypeIncludes(filename, '\\') === false
)
) {
continue;
}
Expand Down

0 comments on commit 096e44a

Please sign in to comment.