Skip to content

Commit 2859b4b

Browse files
HBSPStargos
authored andcommitted
path: change posix.join to use array
Change posix.join to use array.join instead of additional assignment. PR-URL: #54331 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent fcf82ad commit 2859b4b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/path.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1237,20 +1237,20 @@ const posix = {
12371237
join(...args) {
12381238
if (args.length === 0)
12391239
return '.';
1240-
let joined;
1240+
1241+
const path = [];
12411242
for (let i = 0; i < args.length; ++i) {
12421243
const arg = args[i];
12431244
validateString(arg, 'path');
12441245
if (arg.length > 0) {
1245-
if (joined === undefined)
1246-
joined = arg;
1247-
else
1248-
joined += `/${arg}`;
1246+
path.push(arg);
12491247
}
12501248
}
1251-
if (joined === undefined)
1249+
1250+
if (path.length === 0)
12521251
return '.';
1253-
return posix.normalize(joined);
1252+
1253+
return posix.normalize(ArrayPrototypeJoin(path, '/'));
12541254
},
12551255

12561256
/**

0 commit comments

Comments
 (0)