Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Close #598 require('foo') should load '.../foo/foo.js'

  • Loading branch information...
commit 19502080d915e503741577bbe200d6d076e3a06b 1 parent f1b7c42
@isaacs authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/module.js
View
8 lib/module.js
@@ -162,7 +162,7 @@ Module._findPath = function(request, paths) {
// try to join the request to the path
filename = tryFile(basePath);
- if (!filename && !trailingSlash) {
+ if (!filename) {
// try it with each of the extensions
filename = tryExtensions(basePath, exts);
}
@@ -177,6 +177,12 @@ Module._findPath = function(request, paths) {
filename = tryExtensions(path.resolve(basePath, 'index'), exts);
}
+ if (!filename && !trailingSlash) {
+ // try .../foo/foo.js
+ var fooFoo = path.resolve(basePath, path.basename(basePath));
+ filename = tryExtensions(fooFoo, exts);
+ }
+
if (filename) {
Module._pathCache[cacheKey] = filename;
return filename;
Please sign in to comment.
Something went wrong with that request. Please try again.