mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
path: fix posix.relative() on Windows
Fixes: https://github.com/nodejs/node/issues/13683 PR-URL: https://github.com/nodejs/node/pull/37747 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
16
lib/path.js
16
lib/path.js
@@ -23,11 +23,15 @@
|
||||
|
||||
const {
|
||||
FunctionPrototypeBind,
|
||||
RegExp,
|
||||
StringPrototypeCharCodeAt,
|
||||
StringPrototypeIndexOf,
|
||||
StringPrototypeLastIndexOf,
|
||||
StringPrototypeReplace,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeToLowerCase,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
CHAR_UPPERCASE_A,
|
||||
CHAR_LOWERCASE_A,
|
||||
@@ -1014,7 +1018,17 @@ const posix = {
|
||||
let resolvedAbsolute = false;
|
||||
|
||||
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
const path = i >= 0 ? args[i] : process.cwd();
|
||||
let path;
|
||||
if (i >= 0) {
|
||||
path = args[i];
|
||||
} else {
|
||||
const _ = StringPrototypeReplace(
|
||||
process.cwd(),
|
||||
new RegExp(`\\${module.exports.sep}`, 'g'),
|
||||
posix.sep
|
||||
);
|
||||
path = StringPrototypeSlice(_, StringPrototypeIndexOf(_, posix.sep));
|
||||
}
|
||||
|
||||
validateString(path, 'path');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user