From 4d93f35990017be01d1ab0e802971cad7c3a9214 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Sun, 15 Sep 2024 19:35:53 -0700 Subject: [PATCH] os: use const with early return for path --- lib/os.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/os.js b/lib/os.js index bbae40b2ab1046..c88ef443b9b4f2 100644 --- a/lib/os.js +++ b/lib/os.js @@ -180,12 +180,13 @@ platform[SymbolToPrimitive] = () => process.platform; */ function tmpdir() { if (isWindows) { - let path = process.env.TEMP || + const path = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + '\\temp'; + if (path.length > 1 && StringPrototypeEndsWith(path, '\\') && !StringPrototypeEndsWith(path, ':\\')) - path = StringPrototypeSlice(path, 0, -1); + return StringPrototypeSlice(path, 0, -1); return path; }