Skip to content

Commit 1cc81c7

Browse files
HBSPSinjunchoi98
authored andcommitted
path: change posix.join to use array
Change posix.join to use array.join instead of additional assignment. PR-URL: nodejs#54331 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent bd10d6b commit 1cc81c7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/path.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,20 +1269,20 @@ const posix = {
12691269
join(...args) {
12701270
if (args.length === 0)
12711271
return '.';
1272-
let joined;
1272+
1273+
const path = [];
12731274
for (let i = 0; i < args.length; ++i) {
12741275
const arg = args[i];
12751276
validateString(arg, 'path');
12761277
if (arg.length > 0) {
1277-
if (joined === undefined)
1278-
joined = arg;
1279-
else
1280-
joined += `/${arg}`;
1278+
path.push(arg);
12811279
}
12821280
}
1283-
if (joined === undefined)
1281+
1282+
if (path.length === 0)
12841283
return '.';
1285-
return posix.normalize(joined);
1284+
1285+
return posix.normalize(ArrayPrototypeJoin(path, '/'));
12861286
},
12871287

12881288
/**

0 commit comments

Comments
 (0)