|
|
@ -618,7 +618,7 @@ const win32 = { |
|
|
|
// We get here if `from` is the exact base path for `to`.
|
|
|
|
// For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
|
|
|
|
return toOrig.slice(toStart + i + 1); |
|
|
|
} else if (lastCommonSep === 2) { |
|
|
|
} else if (i === 2) { |
|
|
|
// We get here if `from` is the device root.
|
|
|
|
// For example: from='C:\\'; to='C:\\foo'
|
|
|
|
return toOrig.slice(toStart + i); |
|
|
@ -629,7 +629,7 @@ const win32 = { |
|
|
|
// We get here if `to` is the exact base path for `from`.
|
|
|
|
// For example: from='C:\\foo\\bar'; to='C:\\foo'
|
|
|
|
lastCommonSep = i; |
|
|
|
} else if (lastCommonSep === 2) { |
|
|
|
} else if (i === 2) { |
|
|
|
// We get here if `to` is the device root.
|
|
|
|
// For example: from='C:\\foo\\bar'; to='C:\\'
|
|
|
|
lastCommonSep = 3; |
|
|
@ -1299,16 +1299,26 @@ const posix = { |
|
|
|
var i = 0; |
|
|
|
for (; i <= length; ++i) { |
|
|
|
if (i === length) { |
|
|
|
if (lastCommonSep === -1) { |
|
|
|
lastCommonSep = i; |
|
|
|
} else if (toLen > length && to.charCodeAt(i + 1) === 47/*/*/) { |
|
|
|
// We get here if `from` is the exact base path for `to`.
|
|
|
|
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
|
|
return to.slice(i + 2); |
|
|
|
} else if (fromLen > length && from.charCodeAt(i + 1) === 47/*/*/) { |
|
|
|
// We get here if `to` is the exact base path for `from`.
|
|
|
|
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
|
|
lastCommonSep = i; |
|
|
|
if (toLen > length) { |
|
|
|
if (to.charCodeAt(toStart + i) === 47/*/*/) { |
|
|
|
// We get here if `from` is the exact base path for `to`.
|
|
|
|
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
|
|
return to.slice(toStart + i + 1); |
|
|
|
} else if (i === 0) { |
|
|
|
// We get here if `from` is the root
|
|
|
|
// For example: from='/'; to='/foo'
|
|
|
|
return to.slice(toStart + i); |
|
|
|
} |
|
|
|
} else if (fromLen > length) { |
|
|
|
if (from.charCodeAt(fromStart + i) === 47/*/*/) { |
|
|
|
// We get here if `to` is the exact base path for `from`.
|
|
|
|
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
|
|
lastCommonSep = i; |
|
|
|
} else if (i === 0) { |
|
|
|
// We get here if `to` is the root.
|
|
|
|
// For example: from='/foo'; to='/'
|
|
|
|
lastCommonSep = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|