Skip to content

Commit 6545d7d

Browse files
committed
path: remove StringPrototypeCharCodeAt from some methods of posix
Remove `StringPrototypeCharCodeAt` from `posix.resolve`, `posix.normalize`, `posix.parse`
1 parent 420b627 commit 6545d7d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/path.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,7 @@ const posix = {
12621262
}
12631263

12641264
resolvedPath = `${path}/${resolvedPath}`;
1265-
resolvedAbsolute =
1266-
StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH;
1265+
resolvedAbsolute = path[0] === '/';
12671266
}
12681267

12691268
if (!resolvedAbsolute) {
@@ -1296,10 +1295,8 @@ const posix = {
12961295
if (path.length === 0)
12971296
return '.';
12981297

1299-
const isAbsolute =
1300-
StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH;
1301-
const trailingSeparator =
1302-
StringPrototypeCharCodeAt(path, path.length - 1) === CHAR_FORWARD_SLASH;
1298+
const isAbsolute = path[0] === '/';
1299+
const trailingSeparator = path[path.length - 1] === '/';
13031300

13041301
// Normalize the path
13051302
path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
@@ -1639,8 +1636,8 @@ const posix = {
16391636

16401637
// Get non-dir info
16411638
for (; i >= start; --i) {
1642-
const code = StringPrototypeCharCodeAt(path, i);
1643-
if (code === CHAR_FORWARD_SLASH) {
1639+
const char = path[i];
1640+
if (char === '/') {
16441641
// If we reached a path separator that was not part of a set of path
16451642
// separators at the end of the string, stop now
16461643
if (!matchedSlash) {
@@ -1655,7 +1652,7 @@ const posix = {
16551652
matchedSlash = false;
16561653
end = i + 1;
16571654
}
1658-
if (code === CHAR_DOT) {
1655+
if (char === '.') {
16591656
// If this is our first dot, mark it as the start of our extension
16601657
if (startDot === -1)
16611658
startDot = i;

0 commit comments

Comments
 (0)