mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
path: change posix.join to use array
Change posix.join to use array.join instead of additional assignment. PR-URL: https://github.com/nodejs/node/pull/54331 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
14
lib/path.js
14
lib/path.js
@@ -1236,20 +1236,20 @@ const posix = {
|
||||
join(...args) {
|
||||
if (args.length === 0)
|
||||
return '.';
|
||||
let joined;
|
||||
|
||||
const path = [];
|
||||
for (let i = 0; i < args.length; ++i) {
|
||||
const arg = args[i];
|
||||
validateString(arg, 'path');
|
||||
if (arg.length > 0) {
|
||||
if (joined === undefined)
|
||||
joined = arg;
|
||||
else
|
||||
joined += `/${arg}`;
|
||||
path.push(arg);
|
||||
}
|
||||
}
|
||||
if (joined === undefined)
|
||||
|
||||
if (path.length === 0)
|
||||
return '.';
|
||||
return posix.normalize(joined);
|
||||
|
||||
return posix.normalize(ArrayPrototypeJoin(path, '/'));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user