This repository was archived by the owner on Aug 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,14 @@ module.exports = function normalize(path) {
33
33
// i. e. "a/../b/c" => "b/c"
34
34
// i. e. "/../b/c" => "/b/c"
35
35
// i. e. "C:\..\a\b\c" => "C:\a\b\c"
36
- i += 1 ;
37
- sep = ! sep ;
38
- result . length = absolutePathStart ;
36
+ if ( result [ 0 ] !== "." ) {
37
+ i += 1 ;
38
+ sep = ! sep ;
39
+ result . length = absolutePathStart ;
40
+ } else {
41
+ result . length = 0 ;
42
+ result . push ( part ) ;
43
+ }
39
44
break ;
40
45
case 4 :
41
46
// i. e. "a/b/.." => "a"
@@ -88,7 +93,7 @@ module.exports = function normalize(path) {
88
93
result . push ( part ) ;
89
94
}
90
95
}
91
- if ( result . length === 1 && / ^ [ A - Z a - z ] : $ / . test ( result ) )
96
+ if ( result . length === 1 && / ^ [ A - Z a - z ] : $ / . test ( result [ 0 ] ) )
92
97
return result [ 0 ] + "\\" ;
93
98
return result . join ( "" ) ;
94
99
} ;
Original file line number Diff line number Diff line change @@ -359,6 +359,11 @@ describe("normalize", function() {
359
359
fs . normalize ( "C:\\a\\b\\d\\..\\c\\..\\.." ) . should . be . eql ( "C:\\a" ) ;
360
360
fs . normalize ( "C:\\a\\b\\d\\\\.\\\\.\\c\\.\\.." ) . should . be . eql ( "C:\\a\\b\\d" ) ;
361
361
fs . normalize ( "\\\\remote-computer\\c$\\file" ) . should . be . eql ( "\\\\remote-computer\\c$\\file" ) ;
362
+ fs . normalize ( "./../a" ) . should . be . eql ( "../a" ) ;
363
+ fs . normalize ( "/a/./../b" ) . should . be . eql ( "/b" ) ;
364
+ fs . normalize ( "/./../b" ) . should . be . eql ( "/b" ) ;
365
+ fs . normalize ( "C:\\.\\..\\a" ) . should . be . eql ( "C:\\a" ) ;
366
+ fs . normalize ( "C:\\a\\.\\..\\b" ) . should . be . eql ( "C:\\b" ) ;
362
367
} ) ;
363
368
} ) ;
364
369
describe ( "pathToArray" , function ( ) {
You can’t perform that action at this time.
0 commit comments