From 2875ab15c816614fb6755cf16c56519147d90195 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 13 Mar 2021 18:33:07 -0800 Subject: [PATCH] path: fix posix.relative() on Windows Fixes: https://github.com/nodejs/node/issues/13683 --- lib/path.js | 7 +++++-- test/known_issues/known_issues.status | 14 -------------- .../test-path-posix-relative-on-windows.js | 0 3 files changed, 5 insertions(+), 16 deletions(-) rename test/{known_issues => parallel}/test-path-posix-relative-on-windows.js (100%) diff --git a/lib/path.js b/lib/path.js index f3d7f42fc1f433..b5c2945cef3c53 100644 --- a/lib/path.js +++ b/lib/path.js @@ -23,6 +23,7 @@ const { FunctionPrototypeBind, + RegExp, StringPrototypeCharCodeAt, StringPrototypeLastIndexOf, StringPrototypeSlice, @@ -1099,8 +1100,10 @@ const posix = { return ''; // Trim leading forward slashes. - from = posix.resolve(from); - to = posix.resolve(to); + from = module.exports.resolve(from) + .replace(new RegExp(`\\${module.exports.sep}`, 'g'), posix.sep); + to = module.exports.resolve(to) + .replace(new RegExp(`\\${module.exports.sep}`, 'g'), posix.sep); if (from === to) return ''; diff --git a/test/known_issues/known_issues.status b/test/known_issues/known_issues.status index 690e6e9840b77c..7a50c10404c723 100644 --- a/test/known_issues/known_issues.status +++ b/test/known_issues/known_issues.status @@ -15,32 +15,18 @@ test-vm-timeout-escape-queuemicrotask: SKIP [$system==win32] [$system==linux] -# Windows-specific test -test-path-posix-relative-on-windows: SKIP [$system==macos] -# Windows-specific test -test-path-posix-relative-on-windows: SKIP [$system==solaris] -# Windows-specific test -test-path-posix-relative-on-windows: SKIP [$system==freebsd] -# Windows-specific test -test-path-posix-relative-on-windows: SKIP [$system==aix] -# Windows-specific test -test-path-posix-relative-on-windows: SKIP [$arch==arm] # The Raspberry Pis are too slow to run this test. # See https://github.com/nodejs/build/issues/2227#issuecomment-608334574 test-crypto-authenticated-stream: SKIP -# Windows-specific test -test-path-posix-relative-on-windows: SKIP [$system==ibmi] -# Windows-specific test -test-path-posix-relative-on-windows: SKIP diff --git a/test/known_issues/test-path-posix-relative-on-windows.js b/test/parallel/test-path-posix-relative-on-windows.js similarity index 100% rename from test/known_issues/test-path-posix-relative-on-windows.js rename to test/parallel/test-path-posix-relative-on-windows.js