Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed client-side resolution of current and parent indexes

  • Loading branch information...
commit 0bd73e546a2d857c223f336b1c83a57ea2699a35 1 parent e1930c9
@medikoo authored
View
20 lib/webmake.tpl
@@ -12,6 +12,10 @@
isDir = true;
name = path.pop();
}
+ if ((name === '.') || (name === '..')) {
+ path.push(name);
+ name = '';
+ }
while ((dir = path.shift())) {
if (dir === '..') {
scope = tree.pop();
@@ -20,12 +24,16 @@
scope = scope[dir];
}
}
- if (!isDir && scope[name + '.js']) {
- name += '.js';
- }
- if (typeof scope[name] === 'object') {
- tree.push(scope);
- scope = scope[name];
+ if (name) {
+ if (!isDir && scope[name + '.js']) {
+ name += '.js';
+ }
+ if (typeof scope[name] === 'object') {
+ tree.push(scope);
+ scope = scope[name];
+ name = 'index.js';
+ }
+ } else {
name = 'index.js';
}
fn = scope[name];
View
1  test/__playground/lib/index.js
@@ -0,0 +1 @@
+module.exports = 'main.index';
View
6 test/__playground/lib/path/other.js
@@ -1,3 +1,7 @@
'use strict';
-exports.name = 'path/other';
+exports.name = 'path/other';
+exports.index = require('.');
+exports.indexSlash = require('./');
+exports.parentIndex = require('..');
+exports.parentIndexSlash = require('../');
View
6 test/webmake.js
@@ -36,6 +36,12 @@ module.exports = {
a(program.pathDir.name, 'path', "Dir/file collision: dir");
a(program.pathIndex.name, 'path', "Dir/file collision: dir/index");
a(program.pathOther.name, 'path/other', "Dir/file collision: other");
+ a(program.pathOther.index.name, 'path', "'.' - index require");
+ a(program.pathOther.indexSlash.name, 'path',
+ "'./' - index require (slash)");
+ a(program.pathOther.parentIndex, 'main.index', "'..' - parent index");
+ a(program.pathOther.parentIndexSlash,
+ 'main.index', "'../' - parent index (slash)");
a(program.nlComment, 'nlComment', "New line / Comment");
a(program.external.other.name, 'external-other',
"Require module from other package");
Please sign in to comment.
Something went wrong with that request. Please try again.