Skip to content

Commit 1def9ae

Browse files
committed
fix: keep path case
1 parent edca902 commit 1def9ae

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ describe('MatcherPatternPathStatic', () => {
4141
const pattern = new MatcherPatternPathStatic('/')
4242
expect(pattern.build()).toBe('/')
4343
})
44+
45+
it('preserves case', () => {
46+
const pattern = new MatcherPatternPathStatic('/Team')
47+
expect(pattern.build()).toBe('/Team')
48+
})
4449
})
4550
})
4651

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,18 @@ export interface MatcherPatternPath<
6363
export class MatcherPatternPathStatic
6464
implements MatcherPatternPath<EmptyParams>
6565
{
66-
private path: string
67-
constructor(path: string) {
68-
this.path = path.toLowerCase()
66+
/**
67+
* lowercase version of the path to match against.
68+
* This is used to make the matching case insensitive.
69+
*/
70+
private pathi: string
71+
72+
constructor(private path: string) {
73+
this.pathi = path.toLowerCase()
6974
}
7075

7176
match(path: string): EmptyParams {
72-
if (path.toLowerCase() !== this.path) {
77+
if (path.toLowerCase() !== this.pathi) {
7378
throw miss()
7479
}
7580
return {}

0 commit comments

Comments
 (0)