diff --git a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-path-star.ts b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-path-star.ts index 6316c4432..3581700d4 100644 --- a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-path-star.ts +++ b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-path-star.ts @@ -19,12 +19,18 @@ export class MatcherPatternPathStar implements MatcherPatternPath<{ pathMatch: string }> { private path: string + /** + * lowercase version of the path to match against. + * This is used to make the matching case insensitive. + */ + private pathi: string constructor(path: string = '') { - this.path = path.toLowerCase() + this.path = path + this.pathi = path.toLowerCase() } match(path: string): { pathMatch: string } { - if (!path.toLowerCase().startsWith(this.path)) { + if (!path.toLowerCase().startsWith(this.pathi)) { miss() } return { diff --git a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts index 23b689c16..6dd305fd2 100644 --- a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts +++ b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts @@ -126,6 +126,13 @@ describe('MatcherPatternPathStar', () => { const pattern = new MatcherPatternPathStar('/team/') expect(pattern.build({ pathMatch: '/hey' })).toBe('/team//hey') }) + + it('keeps the declared case of the prefix', () => { + const pattern = new MatcherPatternPathStar('/Team') + expect(pattern.build({ pathMatch: '/123' })).toBe('/Team/123') + // match() stays case insensitive + expect(pattern.match('/team/123')).toEqual({ pathMatch: '/123' }) + }) }) })