From 94a457a1ebebbe854ca7a8d9b430a61b04439638 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Tue, 10 Sep 2024 19:29:33 -0400 Subject: [PATCH] path: remove `StringPrototypeCharCodeAt` from `posix.extname` PR-URL: https://github.com/nodejs/node/pull/54546 Reviewed-By: James M Snell Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca --- lib/path.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/path.js b/lib/path.js index 48c7f67dcd617a..e9b56e89a40ee7 100644 --- a/lib/path.js +++ b/lib/path.js @@ -1462,8 +1462,8 @@ const posix = { // after any path separator we find let preDotState = 0; for (let i = path.length - 1; i >= 0; --i) { - const code = StringPrototypeCharCodeAt(path, i); - if (code === CHAR_FORWARD_SLASH) { + const char = path[i]; + if (char === '/') { // If we reached a path separator that was not part of a set of path // separators at the end of the string, stop now if (!matchedSlash) { @@ -1478,7 +1478,7 @@ const posix = { matchedSlash = false; end = i + 1; } - if (code === CHAR_DOT) { + if (char === '.') { // If this is our first dot, mark it as the start of our extension if (startDot === -1) startDot = i;