@@ -618,7 +618,7 @@ const win32 = {
618618            // We get here if `from` is the exact base path for `to`. 
619619            // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz' 
620620            return  toOrig . slice ( toStart  +  i  +  1 ) ; 
621-           }  else  if  ( lastCommonSep  ===  2 )  { 
621+           }  else  if  ( i  ===  2 )  { 
622622            // We get here if `from` is the device root. 
623623            // For example: from='C:\\'; to='C:\\foo' 
624624            return  toOrig . slice ( toStart  +  i ) ; 
@@ -629,7 +629,7 @@ const win32 = {
629629            // We get here if `to` is the exact base path for `from`. 
630630            // For example: from='C:\\foo\\bar'; to='C:\\foo' 
631631            lastCommonSep  =  i ; 
632-           }  else  if  ( lastCommonSep  ===  2 )  { 
632+           }  else  if  ( i  ===  2 )  { 
633633            // We get here if `to` is the device root. 
634634            // For example: from='C:\\foo\\bar'; to='C:\\' 
635635            lastCommonSep  =  3 ; 
@@ -1299,16 +1299,26 @@ const posix = {
12991299    var  i  =  0 ; 
13001300    for  ( ;  i  <=  length ;  ++ i )  { 
13011301      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+           } 
13121322        } 
13131323        break ; 
13141324      } 
0 commit comments