mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
util: improve isInsideNodeModules
PR-URL: https://github.com/nodejs/node/pull/52147 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
7f866a8225
commit
a42b93b9aa
1 file changed
+7
-2
@@ -35,6 +35,7 @@ const {
|
||||
SafeSet,
|
||||
SafeWeakMap,
|
||||
SafeWeakRef,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypeReplace,
|
||||
StringPrototypeToLowerCase,
|
||||
StringPrototypeToUpperCase,
|
||||
@@ -476,7 +477,7 @@ function spliceOne(list, index) {
|
||||
list.pop();
|
||||
}
|
||||
|
||||
const kNodeModulesRE = /^(.*)[\\/]node_modules[\\/]/;
|
||||
const kNodeModulesRE = /^(?:.*)[\\/]node_modules[\\/]/;
|
||||
|
||||
let getStructuredStack;
|
||||
|
||||
@@ -506,8 +507,12 @@ function isInsideNodeModules() {
|
||||
const filename = frame.getFileName();
|
||||
// If a filename does not start with / or contain \,
|
||||
// it's likely from Node.js core.
|
||||
if (RegExpPrototypeExec(/^\/|\\/, filename) === null)
|
||||
if (
|
||||
filename[0] !== '/' &&
|
||||
StringPrototypeIncludes(filename, '\\') === false
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
return RegExpPrototypeExec(kNodeModulesRE, filename) !== null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user