From 1042b58ccf2c401a40de078858ffb7579512e712 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 14 Mar 2021 12:13:12 -0700 Subject: [PATCH] fixup! path: fix posix.relative() on Windows --- lib/path.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/path.js b/lib/path.js index 8ba229a670ab2b..0503669bffebb1 100644 --- a/lib/path.js +++ b/lib/path.js @@ -25,10 +25,13 @@ const { FunctionPrototypeBind, RegExp, StringPrototypeCharCodeAt, + StringPrototypeIndexOf, StringPrototypeLastIndexOf, + StringPrototypeReplace, StringPrototypeSlice, StringPrototypeToLowerCase, } = primordials; + const { CHAR_UPPERCASE_A, CHAR_LOWERCASE_A, @@ -1018,9 +1021,12 @@ const posix = { const path = i >= 0 ? args[i] : (() => { - const _ = process.cwd() - .replace(new RegExp(`\\${module.exports.sep}`, 'g'), posix.sep); - return _.substr(_.indexOf(posix.sep)); + const _ = StringPrototypeReplace( + process.cwd(), + new RegExp(`\\${module.exports.sep}`, 'g'), + posix.sep + ); + return StringPrototypeSlice(_, StringPrototypeIndexOf(_, posix.sep)); })();