Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches require.extensions.hasOwnProperty bug introduced in node.js v8 #49

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 2 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ module.exports = function requireDir(dir, opts) {
// to the map using the full filename as a key also.
var map = {};

for (var base in filesForBase) {
// protect against enumerable object prototype extensions:
if (!filesForBase.hasOwnProperty(base)) {
continue;
}
for (var base of Object.keys(filesForBase)) {

// go through the files for this base and check for directories. we'll
// also create a hash "set" of the non-dir files so that we can
Expand Down Expand Up @@ -92,12 +88,7 @@ module.exports = function requireDir(dir, opts) {
}

// otherwise, go through and try each require.extension key!
for (ext in require.extensions) {
// again protect against enumerable object prototype extensions:
if (!require.extensions.hasOwnProperty(ext)) {
continue;
}

for (ext of Object.keys(require.extensions)) {
// if a file exists with this extension, we'll require() it:
var file = base + ext;
var path = filesMinusDirs[file];
Expand Down