Skip to content

Commit 9aec536

Browse files
HBSPSRafaelGSS
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 <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 66dcb2a commit 9aec536

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
@@ -1236,20 +1236,20 @@ const posix = {
12361236
join(...args) {
12371237
if (args.length === 0)
12381238
return '.';
1239-
let joined;
1239+
1240+
const path = [];
12401241
for (let i = 0; i < args.length; ++i) {
12411242
const arg = args[i];
12421243
validateString(arg, 'path');
12431244
if (arg.length > 0) {
1244-
if (joined === undefined)
1245-
joined = arg;
1246-
else
1247-
joined += `/${arg}`;
1245+
path.push(arg);
12481246
}
12491247
}
1250-
if (joined === undefined)
1248+
1249+
if (path.length === 0)
12511250
return '.';
1252-
return posix.normalize(joined);
1251+
1252+
return posix.normalize(ArrayPrototypeJoin(path, '/'));
12531253
},
12541254

12551255
/**

0 commit comments

Comments
 (0)