@@ -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 ;
@@ -1299,16 +1299,26 @@ const posix = {
1299
1299
var i = 0 ;
1300
1300
for ( ; i <= length ; ++ i ) {
1301
1301
if ( i === length ) {
1302
- if ( lastCommonSep === - 1 ) {
1303
- lastCommonSep = i ;
1304
- } else if ( toLen > length && to . charCodeAt ( i + 1 ) === 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 ( i + 2 ) ;
1308
- } else if ( fromLen > length && from . charCodeAt ( i + 1 ) === 47 /*/*/ ) {
1309
- // We get here if `to` is the exact base path for `from`.
1310
- // For example: from='/foo/bar/baz'; to='/foo/bar'
1311
- lastCommonSep = i ;
1302
+ if ( toLen > length ) {
1303
+ if ( to . charCodeAt ( toStart + i ) === 47 /*/*/ ) {
1304
+ // We get here if `from` is the exact base path for `to`.
1305
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
1306
+ return to . slice ( toStart + i + 1 ) ;
1307
+ } else if ( i === 0 ) {
1308
+ // We get here if `from` is the root
1309
+ // For example: from='/'; to='/foo'
1310
+ return to . slice ( toStart + i ) ;
1311
+ }
1312
+ } else if ( fromLen > length ) {
1313
+ if ( from . charCodeAt ( fromStart + i ) === 47 /*/*/ ) {
1314
+ // We get here if `to` is the exact base path for `from`.
1315
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
1316
+ lastCommonSep = i ;
1317
+ } else if ( i === 0 ) {
1318
+ // We get here if `to` is the root.
1319
+ // For example: from='/foo'; to='/'
1320
+ lastCommonSep = 0 ;
1321
+ }
1312
1322
}
1313
1323
break ;
1314
1324
}
0 commit comments