mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
path: remove StringPrototypeCharCodeAt from some methods of posix
Remove `StringPrototypeCharCodeAt` from `posix.resolve`, `posix.normalize`, `posix.parse`. PR-URL: https://github.com/nodejs/node/pull/54668 Refs: https://github.com/nodejs/node/pull/54546 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
a28496591e
commit
b3fb3440ae
1 file changed
+6
-9
+6
-9
@@ -1262,8 +1262,7 @@ const posix = {
|
||||
}
|
||||
|
||||
resolvedPath = `${path}/${resolvedPath}`;
|
||||
resolvedAbsolute =
|
||||
StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH;
|
||||
resolvedAbsolute = path[0] === '/';
|
||||
}
|
||||
|
||||
if (!resolvedAbsolute) {
|
||||
@@ -1296,10 +1295,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);
|
||||
@@ -1639,8 +1636,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) {
|
||||
@@ -1655,7 +1652,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;
|
||||
|
||||
Reference in new issue
Block a user