Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Comment thread
posva marked this conversation as resolved.
miss()
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
})
})
})

Expand Down
Loading