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 @@ -25,9 +25,14 @@ module.exports = function normalize(path) {
25
25
// i. e. "a/../b/c" => "b/c"
26
26
// i. e. "/../b/c" => "/b/c"
27
27
// i. e. "C:\..\a\b\c" => "C:\a\b\c"
28
- i ++ ;
29
- sep = ! sep ;
30
- result . length = absolutePathStart ;
28
+ if ( result [ 0 ] !== "." ) {
29
+ i ++ ;
30
+ sep = ! sep ;
31
+ result . length = absolutePathStart ;
32
+ } else {
33
+ result . length = 0 ;
34
+ result . push ( part ) ;
35
+ }
31
36
break ;
32
37
case 4 :
33
38
// i. e. "a/b/.." => "a"
@@ -80,7 +85,7 @@ module.exports = function normalize(path) {
80
85
result . push ( part ) ;
81
86
}
82
87
}
83
- if ( result . length === 1 && / ^ [ A - Z a - z ] : $ / . test ( result ) )
88
+ if ( result . length === 1 && / ^ [ A - Z a - z ] : $ / . test ( result [ 0 ] ) )
84
89
return result [ 0 ] + "\\" ;
85
90
return result . join ( "" ) ;
86
91
} ;
Original file line number Diff line number Diff line change @@ -355,6 +355,11 @@ describe("normalize", function() {
355
355
fs . normalize ( "C:\\a\\b\\\c\\..\\.." ) . should . be . eql ( "C:\\a" ) ;
356
356
fs . normalize ( "C:\\a\\b\\d\\..\\c\\..\\.." ) . should . be . eql ( "C:\\a" ) ;
357
357
fs . normalize ( "C:\\a\\b\\d\\\\.\\\\.\\c\\.\\.." ) . should . be . eql ( "C:\\a\\b\\d" ) ;
358
+ fs . normalize ( "./../a" ) . should . be . eql ( "../a" ) ;
359
+ fs . normalize ( "/a/./../b" ) . should . be . eql ( "/b" ) ;
360
+ fs . normalize ( "/./../b" ) . should . be . eql ( "/b" ) ;
361
+ fs . normalize ( "C:\\.\\..\\a" ) . should . be . eql ( "C:\\a" ) ;
362
+ fs . normalize ( "C:\\a\\.\\..\\b" ) . should . be . eql ( "C:\\b" ) ;
358
363
} ) ;
359
364
} ) ;
360
365
describe ( "pathToArray" , function ( ) {
You can’t perform that action at this time.
0 commit comments