Skip to content

Commit 1042b58

Browse files
committed
fixup! path: fix posix.relative() on Windows
1 parent 1121d36 commit 1042b58

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/path.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ const {
2525
FunctionPrototypeBind,
2626
RegExp,
2727
StringPrototypeCharCodeAt,
28+
StringPrototypeIndexOf,
2829
StringPrototypeLastIndexOf,
30+
StringPrototypeReplace,
2931
StringPrototypeSlice,
3032
StringPrototypeToLowerCase,
3133
} = primordials;
34+
3235
const {
3336
CHAR_UPPERCASE_A,
3437
CHAR_LOWERCASE_A,
@@ -1018,9 +1021,12 @@ const posix = {
10181021
const path = i >= 0 ?
10191022
args[i] :
10201023
(() => {
1021-
const _ = process.cwd()
1022-
.replace(new RegExp(`\\${module.exports.sep}`, 'g'), posix.sep);
1023-
return _.substr(_.indexOf(posix.sep));
1024+
const _ = StringPrototypeReplace(
1025+
process.cwd(),
1026+
new RegExp(`\\${module.exports.sep}`, 'g'),
1027+
posix.sep
1028+
);
1029+
return StringPrototypeSlice(_, StringPrototypeIndexOf(_, posix.sep));
10241030
})();
10251031

10261032

0 commit comments

Comments
 (0)