From 5bc8894e5d37b9d86bd191c9cbc33fe2bb26637a Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 14 Aug 2025 15:53:09 +0200 Subject: [PATCH] fix: star pattern must start --- .../experimental/route-resolver/matchers/matcher-pattern.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts index f7321d3e..68189915 100644 --- a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts +++ b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts @@ -88,6 +88,7 @@ export class MatcherPatternPathStatic * ```ts * const matcher = new MatcherPatternPathStar('/team') * matcher.match('/team/123') // { pathMatch: '/123' } + * matcher.match('/team/123/more') // { pathMatch: '/123/more' } * matcher.match('/team-123') // { pathMatch: '-123' } * matcher.match('/team') // { pathMatch: '' } * matcher.build({ pathMatch: '/123' }) // '/team/123' @@ -102,12 +103,11 @@ export class MatcherPatternPathStar } match(path: string): { pathMatch: string } { - const pathMatchIndex = path.toLowerCase().indexOf(this.path) - if (pathMatchIndex < 0) { + if (!path.toLowerCase().startsWith(this.path)) { throw miss() } return { - pathMatch: path.slice(pathMatchIndex + this.path.length), + pathMatch: path.slice(this.path.length), } } -- 2.47.3