Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
module: fix unintended mutation
  • Loading branch information
aduh95 committed Jan 5, 2023
commit 8829b0debc567b31332f85f1b413f029f3abf483
10 changes: 5 additions & 5 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const {
ArrayPrototypeJoin,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypePushApply,
ArrayPrototypeSlice,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
Expand Down Expand Up @@ -668,12 +669,11 @@ Module._findPath = function(request, paths, isMain) {
return filename;
}

if (exts === undefined) {
exts = [''];
} else {
ArrayPrototypeUnshift(exts, '');
const extensions = [''];
if (exts !== undefined) {
ArrayPrototypePushApply(extensions, exts);
}
reportModuleNotFoundToWatchMode(basePath, exts);
reportModuleNotFoundToWatchMode(basePath, extensions);
}

return false;
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/require-resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ assert.strictEqual(
require.resolve('./printA.js', {}),
require.resolve('./printA.js')
);

assert.strictEqual(
require.resolve('no_index/'),
path.join(__dirname, 'node_modules', 'no_index', 'lib', 'index.js'),
)