Skip to content

Commit

Permalink
Only fetch the next character when necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed Dec 17, 2024
1 parent baaa850 commit 3a27437
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/compiler/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,18 +644,17 @@ function isNotNormalizedOrAbsolute(s: string) {

for (let i = 0, n = s.length - 1; i < n; i++) {
const curr = s.charCodeAt(i);
const next = s.charCodeAt(i + 1);
if (curr === CharacterCodes.dot) {
// A ./ or ../ must be reduced - not normalized.
if (next === CharacterCodes.slash) {
if (s.charCodeAt(i + 1) === CharacterCodes.slash) {
return true;
}
}
else if (curr === CharacterCodes.slash) {
// Multiple slashes in a row (outside of the root,
// and there is no root) must be reduced to a single slash.
// So the path is not normalized.
if (next === CharacterCodes.slash) {
if (s.charCodeAt(i + 1) === CharacterCodes.slash) {
return true;
}
}
Expand Down

0 comments on commit 3a27437

Please sign in to comment.