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 a42b93b

Browse filesBrowse files
Uzlopaktargos
authored andcommitted
util: improve isInsideNodeModules
PR-URL: #52147 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 7f866a8 commit a42b93b
Copy full SHA for a42b93b

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/util.js
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const {
3535
SafeSet,
3636
SafeWeakMap,
3737
SafeWeakRef,
38+
StringPrototypeIncludes,
3839
StringPrototypeReplace,
3940
StringPrototypeToLowerCase,
4041
StringPrototypeToUpperCase,
@@ -476,7 +477,7 @@ function spliceOne(list, index) {
476477
list.pop();
477478
}
478479

479-
const kNodeModulesRE = /^(.*)[\\/]node_modules[\\/]/;
480+
const kNodeModulesRE = /^(?:.*)[\\/]node_modules[\\/]/;
480481

481482
let getStructuredStack;
482483

@@ -506,8 +507,12 @@ function isInsideNodeModules() {
506507
const filename = frame.getFileName();
507508
// If a filename does not start with / or contain \,
508509
// it's likely from Node.js core.
509-
if (RegExpPrototypeExec(/^\/|\\/, filename) === null)
510+
if (
511+
filename[0] !== '/' &&
512+
StringPrototypeIncludes(filename, '\\') === false
513+
) {
510514
continue;
515+
}
511516
return RegExpPrototypeExec(kNodeModulesRE, filename) !== null;
512517
}
513518
}

0 commit comments

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