From 2859b4ba9ab9aae47d3576847cd157839900fe4a 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 fa1ceadb697e28..e1e2591bfc448a 100644 --- a/lib/path.js +++ b/lib/path.js @@ -1237,20 +1237,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, '/')); }, /**