Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path: remove StringPrototypeCharCodeAt from some methods of posix #54668

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
Loading