path: fix path.relative UNC path result
When the result of a path.relative() is an absolute UNC path, it should include the leading backslashes. Fixes: https://github.com/nodejs/node/issues/8444 PR-URL: https://github.com/nodejs/node/pull/8523 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
This commit is contained in:
parent
0f7fffb329
commit
c1e47ed8c8
@ -619,11 +619,7 @@ const win32 = {
|
|||||||
|
|
||||||
// We found a mismatch before the first common path separator was seen, so
|
// We found a mismatch before the first common path separator was seen, so
|
||||||
// return the original `to`.
|
// return the original `to`.
|
||||||
// TODO: do this just for device roots (and not UNC paths)?
|
|
||||||
if (i !== length && lastCommonSep === -1) {
|
if (i !== length && lastCommonSep === -1) {
|
||||||
if (toStart > 0)
|
|
||||||
return toOrig.slice(toStart);
|
|
||||||
else
|
|
||||||
return toOrig;
|
return toOrig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +492,9 @@ const relativeTests = [
|
|||||||
['C:\\baz-quux', 'C:\\baz', '..\\baz'],
|
['C:\\baz-quux', 'C:\\baz', '..\\baz'],
|
||||||
['C:\\baz', 'C:\\baz-quux', '..\\baz-quux'],
|
['C:\\baz', 'C:\\baz-quux', '..\\baz-quux'],
|
||||||
['\\\\foo\\baz-quux', '\\\\foo\\baz', '..\\baz'],
|
['\\\\foo\\baz-quux', '\\\\foo\\baz', '..\\baz'],
|
||||||
['\\\\foo\\baz', '\\\\foo\\baz-quux', '..\\baz-quux']
|
['\\\\foo\\baz', '\\\\foo\\baz-quux', '..\\baz-quux'],
|
||||||
|
['C:\\baz', '\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz'],
|
||||||
|
['\\\\foo\\bar\\baz', 'C:\\baz', 'C:\\baz']
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[ path.posix.relative,
|
[ path.posix.relative,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user