@@ -618,7 +618,7 @@ const win32 = {
618
618
// We get here if `from` is the exact base path for `to`.
619
619
// For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
620
620
return toOrig . slice ( toStart + i + 1 ) ;
621
- } else if ( lastCommonSep === 2 ) {
621
+ } else if ( i === 2 ) {
622
622
// We get here if `from` is the device root.
623
623
// For example: from='C:\\'; to='C:\\foo'
624
624
return toOrig . slice ( toStart + i ) ;
@@ -629,7 +629,7 @@ const win32 = {
629
629
// We get here if `to` is the exact base path for `from`.
630
630
// For example: from='C:\\foo\\bar'; to='C:\\foo'
631
631
lastCommonSep = i ;
632
- } else if ( lastCommonSep === 2 ) {
632
+ } else if ( i === 2 ) {
633
633
// We get here if `to` is the device root.
634
634
// For example: from='C:\\foo\\bar'; to='C:\\'
635
635
lastCommonSep = 3 ;
@@ -1300,16 +1300,26 @@ const posix = {
1300
1300
var i = 0 ;
1301
1301
for ( ; i <= length ; ++ i ) {
1302
1302
if ( i === length ) {
1303
- if ( lastCommonSep === - 1 ) {
1304
- lastCommonSep = i ;
1305
- } else if ( toLen > length && to . charCodeAt ( i + 1 ) === 47 /*/*/ ) {
1306
- // We get here if `from` is the exact base path for `to`.
1307
- // For example: from='/foo/bar'; to='/foo/bar/baz'
1308
- return to . slice ( i + 2 ) ;
1309
- } else if ( fromLen > length && from . charCodeAt ( i + 1 ) === 47 /*/*/ ) {
1310
- // We get here if `to` is the exact base path for `from`.
1311
- // For example: from='/foo/bar/baz'; to='/foo/bar'
1312
- lastCommonSep = i ;
1303
+ if ( toLen > length ) {
1304
+ if ( to . charCodeAt ( toStart + i ) === 47 /*/*/ ) {
1305
+ // We get here if `from` is the exact base path for `to`.
1306
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
1307
+ return to . slice ( toStart + i + 1 ) ;
1308
+ } else if ( i === 0 ) {
1309
+ // We get here if `from` is the root
1310
+ // For example: from='/'; to='/foo'
1311
+ return to . slice ( toStart + i ) ;
1312
+ }
1313
+ } else if ( fromLen > length ) {
1314
+ if ( from . charCodeAt ( fromStart + i ) === 47 /*/*/ ) {
1315
+ // We get here if `to` is the exact base path for `from`.
1316
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
1317
+ lastCommonSep = i ;
1318
+ } else if ( i === 0 ) {
1319
+ // We get here if `to` is the root.
1320
+ // For example: from='/foo'; to='/'
1321
+ lastCommonSep = 0 ;
1322
+ }
1313
1323
}
1314
1324
break ;
1315
1325
}
0 commit comments