Skip to content

Commit 2875ab1

Browse files
committed
path: fix posix.relative() on Windows
Fixes: #13683
1 parent 85edaf4 commit 2875ab1

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

lib/path.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const {
2525
FunctionPrototypeBind,
26+
RegExp,
2627
StringPrototypeCharCodeAt,
2728
StringPrototypeLastIndexOf,
2829
StringPrototypeSlice,
@@ -1099,8 +1100,10 @@ const posix = {
10991100
return '';
11001101

11011102
// Trim leading forward slashes.
1102-
from = posix.resolve(from);
1103-
to = posix.resolve(to);
1103+
from = module.exports.resolve(from)
1104+
.replace(new RegExp(`\\${module.exports.sep}`, 'g'), posix.sep);
1105+
to = module.exports.resolve(to)
1106+
.replace(new RegExp(`\\${module.exports.sep}`, 'g'), posix.sep);
11041107

11051108
if (from === to)
11061109
return '';

test/known_issues/known_issues.status

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,18 @@ test-vm-timeout-escape-queuemicrotask: SKIP
1515
[$system==win32]
1616

1717
[$system==linux]
18-
# Windows-specific test
19-
test-path-posix-relative-on-windows: SKIP
2018

2119
[$system==macos]
22-
# Windows-specific test
23-
test-path-posix-relative-on-windows: SKIP
2420

2521
[$system==solaris]
26-
# Windows-specific test
27-
test-path-posix-relative-on-windows: SKIP
2822

2923
[$system==freebsd]
30-
# Windows-specific test
31-
test-path-posix-relative-on-windows: SKIP
3224

3325
[$system==aix]
34-
# Windows-specific test
35-
test-path-posix-relative-on-windows: SKIP
3626

3727
[$arch==arm]
3828
# The Raspberry Pis are too slow to run this test.
3929
# See https://github.com/nodejs/build/issues/2227#issuecomment-608334574
4030
test-crypto-authenticated-stream: SKIP
41-
# Windows-specific test
42-
test-path-posix-relative-on-windows: SKIP
4331

4432
[$system==ibmi]
45-
# Windows-specific test
46-
test-path-posix-relative-on-windows: SKIP

test/known_issues/test-path-posix-relative-on-windows.js renamed to test/parallel/test-path-posix-relative-on-windows.js

File renamed without changes.

0 commit comments

Comments
 (0)