diff --git a/lib/module.js b/lib/module.js index 30e1f72a256855..b2ddbd80c31913 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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 = []; diff --git a/test/fixtures/module-require/relative/dot-slash.js b/test/fixtures/module-require/relative/dot-slash.js new file mode 100644 index 00000000000000..9817d8d4a6b4a2 --- /dev/null +++ b/test/fixtures/module-require/relative/dot-slash.js @@ -0,0 +1 @@ +module.exports = require('./'); diff --git a/test/fixtures/module-require/relative/dot.js b/test/fixtures/module-require/relative/dot.js new file mode 100644 index 00000000000000..edac839e948e8b --- /dev/null +++ b/test/fixtures/module-require/relative/dot.js @@ -0,0 +1 @@ +module.exports = require('.'); diff --git a/test/fixtures/module-require/relative/index.js b/test/fixtures/module-require/relative/index.js new file mode 100644 index 00000000000000..f16abdc55b3f4c --- /dev/null +++ b/test/fixtures/module-require/relative/index.js @@ -0,0 +1 @@ +exports.value = 42; diff --git a/test/parallel/test-require-extensions-main.js b/test/parallel/test-require-extensions-main.js index 032f2eb2c983da..2a102afc950f77 100644 --- a/test/parallel/test-require-extensions-main.js +++ b/test/parallel/test-require-extensions-main.js @@ -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("./")');