From 9aec5360837f4ecdc78d200d19029c016579b96e Mon Sep 17 00:00:00 2001 From: Wiyeong Seo Date: Wed, 14 Aug 2024 20:18:49 +0900 Subject: [PATCH] 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 Reviewed-By: Yagiz Nizipli --- lib/path.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/path.js b/lib/path.js index eba07f376ad0f9..48c7f67dcd617a 100644 --- a/lib/path.js +++ b/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, '/')); }, /**