diff --git a/lib/path.js b/lib/path.js index 5637b328c1da98..f2fb19edd9ecb1 100644 --- a/lib/path.js +++ b/lib/path.js @@ -619,12 +619,8 @@ const win32 = { // We found a mismatch before the first common path separator was seen, so // return the original `to`. - // TODO: do this just for device roots (and not UNC paths)? if (i !== length && lastCommonSep === -1) { - if (toStart > 0) - return toOrig.slice(toStart); - else - return toOrig; + return toOrig; } var out = ''; diff --git a/test/parallel/test-path.js b/test/parallel/test-path.js index 5aa60eb7c66b0d..cc6b302df436b4 100644 --- a/test/parallel/test-path.js +++ b/test/parallel/test-path.js @@ -492,7 +492,9 @@ const relativeTests = [ ['C:\\baz-quux', 'C:\\baz', '..\\baz'], ['C:\\baz', 'C:\\baz-quux', '..\\baz-quux'], ['\\\\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,