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
9 changes: 8 additions & 1 deletion src/catu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,17 @@ describe('Common Access Token Uri', () => {
test('can match query params', async () => {
const catu = CommonAccessTokenUri.fromDict({
query: {
'exact-match': 'z=z&x=true&y=false'
'exact-match': '?z=z&x=true&y=false'
}
});
const uri = new URL('https://example.com/path?y=false&x=true&z=z');
expect(await catu.match(uri)).toBeTruthy();
const catu2 = CommonAccessTokenUri.fromDict({
query: {
'exact-match': 'z=z&x=true&y=false'
}
});
const uri2 = new URL('https://example.com/path?y=false&x=true&z=z');
expect(await catu2.match(uri2)).toBeTruthy();
});
});
5 changes: 4 additions & 1 deletion src/catu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,11 @@ export class CommonAccessTokenUri {
params.delete('cat');
params.sort();
value = params.toString();
const matchValueString = matchValue as string;
const matchValueParams = new URLSearchParams(
'?' + (matchValue as string)
!matchValueString.startsWith('?')
? '?' + matchValueString
: matchValueString
);
matchValueParams.sort();
matchValue = matchValueParams.toString();
Expand Down
Loading