Skip to content

Commit 58da76f

Browse files
committed
Use for-of loops in route manifest pattern matching
1 parent fad4b93 commit 58da76f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/react/src/reactrouter-compat-utils/route-manifest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ function matchesPattern(pathname: string, pattern: string): boolean {
7777

7878
if (hasWildcard) {
7979
// Pattern with wildcard: path must have at least as many segments as pattern (minus wildcard)
80-
const patternSegmentsWithoutWildcard = patternSegments.length - 1;
81-
if (pathSegments.length < patternSegmentsWithoutWildcard) {
80+
const patternSegmentsWithoutWildcard = patternSegments.slice(0, -1);
81+
if (pathSegments.length < patternSegmentsWithoutWildcard.length) {
8282
return false;
8383
}
84-
for (let i = 0; i < patternSegmentsWithoutWildcard; i++) {
85-
if (!segmentMatches(pathSegments[i], patternSegments[i])) {
84+
for (const [i, patternSegment] of patternSegmentsWithoutWildcard.entries()) {
85+
if (!segmentMatches(pathSegments[i], patternSegment)) {
8686
return false;
8787
}
8888
}
@@ -94,8 +94,8 @@ function matchesPattern(pathname: string, pattern: string): boolean {
9494
return false;
9595
}
9696

97-
for (let i = 0; i < patternSegments.length; i++) {
98-
if (!segmentMatches(pathSegments[i], patternSegments[i])) {
97+
for (const [i, patternSegment] of patternSegments.entries()) {
98+
if (!segmentMatches(pathSegments[i], patternSegment)) {
9999
return false;
100100
}
101101
}

0 commit comments

Comments
 (0)