From 5cc5e1a65afb5883dc638153913acea3a4bf982c Mon Sep 17 00:00:00 2001 From: Brian White Date: Fri, 2 Aug 2019 21:04:56 -0400 Subject: [PATCH] path: improve normalization performance --- lib/path.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/path.js b/lib/path.js index e278c891482070..884da4cd8e6822 100644 --- a/lib/path.js +++ b/lib/path.js @@ -95,7 +95,10 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) { lastSegmentLength = 2; } } else { - res += (res.length > 0 ? separator : '') + path.slice(lastSlash + 1, i); + if (res.length > 0) + res += `${separator}${path.slice(lastSlash + 1, i)}`; + else + res = path.slice(lastSlash + 1, i); lastSegmentLength = i - lastSlash - 1; } lastSlash = i;