Skip to content

Commit 5bc8894

Browse files
committed
fix: star pattern must start
1 parent f8b6781 commit 5bc8894

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class MatcherPatternPathStatic
8888
* ```ts
8989
* const matcher = new MatcherPatternPathStar('/team')
9090
* matcher.match('/team/123') // { pathMatch: '/123' }
91+
* matcher.match('/team/123/more') // { pathMatch: '/123/more' }
9192
* matcher.match('/team-123') // { pathMatch: '-123' }
9293
* matcher.match('/team') // { pathMatch: '' }
9394
* matcher.build({ pathMatch: '/123' }) // '/team/123'
@@ -102,12 +103,11 @@ export class MatcherPatternPathStar
102103
}
103104

104105
match(path: string): { pathMatch: string } {
105-
const pathMatchIndex = path.toLowerCase().indexOf(this.path)
106-
if (pathMatchIndex < 0) {
106+
if (!path.toLowerCase().startsWith(this.path)) {
107107
throw miss()
108108
}
109109
return {
110-
pathMatch: path.slice(pathMatchIndex + this.path.length),
110+
pathMatch: path.slice(this.path.length),
111111
}
112112
}
113113

0 commit comments

Comments
 (0)