Skip to content

Commit

Permalink
Don't try to run extension loaders unless they're actually functions
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs authored and ry committed Sep 22, 2010
1 parent 9922e4e commit dff1b5a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ var module = (function () {
this.filename = filename;

var extension = path.extname(filename) || '.js';
if (!extensions[extension]) extension = '.js';
extensions[extension](this, filename);
this.loaded = true;
};
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/registerExt.hello.world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.test = 'passed'
2 changes: 2 additions & 0 deletions test/simple/test-module-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ require.extensions['.test'] = function (module, filename) {
};

assert.equal(require('../fixtures/registerExt').test, "passed");
// unknown extension, load as .js
assert.equal(require('../fixtures/registerExt.hello.world').test, "passed");

common.debug('load custom file types that return non-strings');
require.extensions['.test'] = function (module, filename) {
Expand Down

0 comments on commit dff1b5a

Please sign in to comment.