diff --git a/lib/path.js b/lib/path.js index 48c7f67dcd617a..674e2334a374ba 100644 --- a/lib/path.js +++ b/lib/path.js @@ -1173,8 +1173,7 @@ const posix = { } resolvedPath = `${path}/${resolvedPath}`; - resolvedAbsolute = - StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH; + resolvedAbsolute = path[0] === '/'; } // At this point the path should be resolved to a full absolute path, but @@ -1200,10 +1199,8 @@ const posix = { if (path.length === 0) return '.'; - const isAbsolute = - StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH; - const trailingSeparator = - StringPrototypeCharCodeAt(path, path.length - 1) === CHAR_FORWARD_SLASH; + const isAbsolute = path[0] === '/'; + const trailingSeparator = path[path.length - 1] === '/'; // Normalize the path path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator); @@ -1543,8 +1540,8 @@ const posix = { // Get non-dir info for (; i >= start; --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) { @@ -1559,7 +1556,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;