File tree Expand file tree Collapse file tree 4 files changed +26
-7
lines changed Expand file tree Collapse file tree 4 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 12
12
isDir = true ;
13
13
name = path.pop();
14
14
}
15
+ if ((name === '.') || (name === '..')) {
16
+ path.push(name);
17
+ name = ' ' ;
18
+ }
15
19
while ((dir = path.shift())) {
16
20
if (dir === ' ..' ) {
17
21
scope = tree.pop();
20
24
scope = scope[dir];
21
25
}
22
26
}
23
- if (!isDir && scope[name + '.js']) {
24
- name += ' .js' ;
25
- }
26
- if (typeof scope[name] === 'object') {
27
- tree.push(scope);
28
- scope = scope[name];
27
+ if (name) {
28
+ if (! isDir && scope[name + ' .js' ]) {
29
+ name += ' .js' ;
30
+ }
31
+ if (typeof scope[name] === 'object') {
32
+ tree.push(scope);
33
+ scope = scope[name];
34
+ name = ' index.js' ;
35
+ }
36
+ } else {
29
37
name = ' index.js' ;
30
38
}
31
39
fn = scope[name];
Original file line number Diff line number Diff line change
1
+ module . exports = 'main.index' ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- exports . name = 'path/other' ;
3
+ exports . name = 'path/other' ;
4
+ exports . index = require ( '.' ) ;
5
+ exports . indexSlash = require ( './' ) ;
6
+ exports . parentIndex = require ( '..' ) ;
7
+ exports . parentIndexSlash = require ( '../' ) ;
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ module.exports = {
36
36
a ( program . pathDir . name , 'path' , "Dir/file collision: dir" ) ;
37
37
a ( program . pathIndex . name , 'path' , "Dir/file collision: dir/index" ) ;
38
38
a ( program . pathOther . name , 'path/other' , "Dir/file collision: other" ) ;
39
+ a ( program . pathOther . index . name , 'path' , "'.' - index require" ) ;
40
+ a ( program . pathOther . indexSlash . name , 'path' ,
41
+ "'./' - index require (slash)" ) ;
42
+ a ( program . pathOther . parentIndex , 'main.index' , "'..' - parent index" ) ;
43
+ a ( program . pathOther . parentIndexSlash ,
44
+ 'main.index' , "'../' - parent index (slash)" ) ;
39
45
a ( program . nlComment , 'nlComment' , "New line / Comment" ) ;
40
46
a ( program . external . other . name , 'external-other' ,
41
47
"Require module from other package" ) ;
You can’t perform that action at this time.
0 commit comments