Skip to content

Commit

Permalink
module: fix require('.')
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Mar 20, 2015
1 parent 2b63bcd commit acc1455
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Module._resolveLookupPaths = function(request, parent) {
}

var start = request.substring(0, 2);
if (start !== './' && start !== '..') {
if (start !== '.' && start !== './' && start !== '..') {
var paths = modulePaths;
if (parent) {
if (!parent.paths) parent.paths = [];
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/module-require/relative/dot-slash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./');
1 change: 1 addition & 0 deletions test/fixtures/module-require/relative/dot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('.');
1 change: 1 addition & 0 deletions test/fixtures/module-require/relative/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.value = 42;
6 changes: 6 additions & 0 deletions test/parallel/test-require-extensions-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ var common = require('../common');
var assert = require('assert');

require(common.fixturesDir + '/require-bin/bin/req.js');

var a = require(common.fixturesDir + '/module-require/relative/dot.js');
var b = require(common.fixturesDir + '/module-require/relative/dot-slash.js');

assert.equal(a.value, 42);
assert.equal(a, b, 'require(".") should resolve like require("./")');

0 comments on commit acc1455

Please sign in to comment.