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 baf30ee

Browse filesBrowse files
aduh95juanarbol
authored andcommitted
module: fix unintended mutation
Refs: #46061 (comment) PR-URL: #46108 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent 24a1016 commit baf30ee
Copy full SHA for baf30ee

File tree

Expand file treeCollapse file tree

2 files changed

+10
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const {
2929
ArrayPrototypeJoin,
3030
ArrayPrototypeMap,
3131
ArrayPrototypePush,
32+
ArrayPrototypePushApply,
3233
ArrayPrototypeSlice,
3334
ArrayPrototypeSplice,
3435
ArrayPrototypeUnshift,
@@ -655,12 +656,11 @@ Module._findPath = function(request, paths, isMain) {
655656
return filename;
656657
}
657658

658-
if (exts === undefined) {
659-
exts = [''];
660-
} else {
661-
ArrayPrototypeUnshift(exts, '');
659+
const extensions = [''];
660+
if (exts !== undefined) {
661+
ArrayPrototypePushApply(extensions, exts);
662662
}
663-
reportModuleNotFoundToWatchMode(basePath, exts);
663+
reportModuleNotFoundToWatchMode(basePath, extensions);
664664
}
665665

666666
return false;
Collapse file

‎test/fixtures/require-resolve.js‎

Copy file name to clipboardExpand all lines: test/fixtures/require-resolve.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,8 @@ assert.strictEqual(
9898
require.resolve('./printA.js', {}),
9999
require.resolve('./printA.js')
100100
);
101+
102+
assert.strictEqual(
103+
require.resolve('no_index/'),
104+
path.join(__dirname, 'node_modules', 'no_index', 'lib', 'index.js'),
105+
)

0 commit comments

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