File tree 2 files changed +23
-8
lines changed
2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -603,14 +603,28 @@ const win32 = {
603
603
var i = 0 ;
604
604
for ( ; i <= length ; ++ i ) {
605
605
if ( i === length ) {
606
- if ( lastCommonSep > 2 && // ignore separator match following device root
607
- toLen > length &&
608
- to . charCodeAt ( i ) === 92 /*\*/ ) {
609
- // We get here if `from` is the exact base path for `to`.
610
- // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
611
- return toOrig . slice ( i + 1 ) ;
606
+ if ( toLen > length ) {
607
+ if ( to . charCodeAt ( toStart + i ) === 92 /*\*/ ) {
608
+ // We get here if `from` is the exact base path for `to`.
609
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
610
+ return toOrig . slice ( toStart + i + 1 ) ;
611
+ } else if ( lastCommonSep === 2 ) {
612
+ // We get here if `from` is the device root.
613
+ // For example: from='C:\\'; to='C:\\foo'
614
+ return toOrig . slice ( toStart + i ) ;
615
+ }
616
+ }
617
+ if ( fromLen > length ) {
618
+ if ( from . charCodeAt ( fromStart + i ) === 92 /*\*/ ) {
619
+ // We get here if `to` is the exact base path for `from`.
620
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
621
+ lastCommonSep = i ;
622
+ } else if ( lastCommonSep === 2 ) {
623
+ // We get here if `to` is the device root.
624
+ // For example: from='C:\\foo\\bar'; to='C:\\'
625
+ lastCommonSep = 3 ;
626
+ }
612
627
}
613
- lastCommonSep = i ;
614
628
break ;
615
629
}
616
630
var fromCode = from . charCodeAt ( fromStart + i ) ;
Original file line number Diff line number Diff line change @@ -470,7 +470,8 @@ const relativeTests = [
470
470
[ 'c:/AaAa/bbbb' , 'c:/aaaa/bbbb' , '' ] ,
471
471
[ 'c:/aaaaa/' , 'c:/aaaa/cccc' , '..\\aaaa\\cccc' ] ,
472
472
[ 'C:\\foo\\bar\\baz\\quux' , 'C:\\' , '..\\..\\..\\..' ] ,
473
- [ 'C:\\foo\\test' , 'C:\\foo\\test\\bar\\package.json' , 'bar\\package.json' ]
473
+ [ 'C:\\foo\\test' , 'C:\\foo\\test\\bar\\package.json' , 'bar\\package.json' ] ,
474
+ [ 'C:\\foo\\bar\\baz-quux' , 'C:\\foo\\bar\\baz' , '..\\baz' ]
474
475
]
475
476
] ,
476
477
[ path . posix . relative ,
You can’t perform that action at this time.
0 commit comments