Skip to content

Commit 87074fe

Browse files
committed
path: remove StringPrototypeCharCodeAt from lib/path
Remove `StringPrototypeCharCodeAt` from `posix.resolve`, `posix.normalize`, `posix.parse`
1 parent d6f5234 commit 87074fe

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/path.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,7 @@ const posix = {
11731173
}
11741174

11751175
resolvedPath = `${path}/${resolvedPath}`;
1176-
resolvedAbsolute =
1177-
StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH;
1176+
resolvedAbsolute = path[0] === '/';
11781177
}
11791178

11801179
// At this point the path should be resolved to a full absolute path, but
@@ -1200,10 +1199,8 @@ const posix = {
12001199
if (path.length === 0)
12011200
return '.';
12021201

1203-
const isAbsolute =
1204-
StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH;
1205-
const trailingSeparator =
1206-
StringPrototypeCharCodeAt(path, path.length - 1) === CHAR_FORWARD_SLASH;
1202+
const isAbsolute = path[0] === '/';
1203+
const trailingSeparator = path[path.length - 1] === '/';
12071204

12081205
// Normalize the path
12091206
path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
@@ -1543,8 +1540,8 @@ const posix = {
15431540

15441541
// Get non-dir info
15451542
for (; i >= start; --i) {
1546-
const code = StringPrototypeCharCodeAt(path, i);
1547-
if (code === CHAR_FORWARD_SLASH) {
1543+
const code = path[i];
1544+
if (code === '/') {
15481545
// If we reached a path separator that was not part of a set of path
15491546
// separators at the end of the string, stop now
15501547
if (!matchedSlash) {
@@ -1559,7 +1556,7 @@ const posix = {
15591556
matchedSlash = false;
15601557
end = i + 1;
15611558
}
1562-
if (code === CHAR_DOT) {
1559+
if (code === '.') {
15631560
// If this is our first dot, mark it as the start of our extension
15641561
if (startDot === -1)
15651562
startDot = i;

0 commit comments

Comments
 (0)