From 5c8495349a79ee929f9e4d86893843a19919ab56 Mon Sep 17 00:00:00 2001 From: William Chargin Date: Sat, 11 Aug 2018 11:23:42 -0700 Subject: [PATCH] path: remove unnecessary if statement There is an `if`-statement in `normalizeString` (a helper function for `path.normalize`) whose `else`-branch is never taken. This patch removes it. PR-URL: https://github.com/nodejs/node/pull/22273 Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/path.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/path.js b/lib/path.js index 90129f1f52989e..c8d92f14af04de 100644 --- a/lib/path.js +++ b/lib/path.js @@ -77,18 +77,16 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) { res.charCodeAt(res.length - 2) !== CHAR_DOT) { if (res.length > 2) { const lastSlashIndex = res.lastIndexOf(separator); - if (lastSlashIndex !== res.length - 1) { - if (lastSlashIndex === -1) { - res = ''; - lastSegmentLength = 0; - } else { - res = res.slice(0, lastSlashIndex); - lastSegmentLength = res.length - 1 - res.lastIndexOf(separator); - } - lastSlash = i; - dots = 0; - continue; + if (lastSlashIndex === -1) { + res = ''; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf(separator); } + lastSlash = i; + dots = 0; + continue; } else if (res.length === 2 || res.length === 1) { res = ''; lastSegmentLength = 0;