Skip to content

Commit

Permalink
Fix captcha route parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds-signal committed Nov 10, 2023
1 parent fea85d3 commit 31d680d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ts/test-node/util/signalRoutes_test.ts
Expand Up @@ -106,12 +106,14 @@ describe('signalRoutes', () => {
});

it('captcha', () => {
const captchaId =
'signal-hcaptcha.foo-bar_baz.challenge.foo-bar_baz.foo-bar_baz';
const result: ParsedSignalRoute = {
key: 'captcha',
args: { captchaId: 'foobar' },
args: { captchaId },
};
const check = createCheck({ hasWebUrl: false });
check('signalcaptcha://foobar', result);
check(`signalcaptcha://${captchaId}`, result);
});

it('linkCall', () => {
Expand Down
5 changes: 3 additions & 2 deletions ts/util/signalRoutes.ts
Expand Up @@ -48,7 +48,7 @@ type AllHostnamePatterns =
| 'start-call-lobby'
| 'show-window'
| 'set-is-presenting'
| ':captchaId'
| ':captchaId(.+)'
| '';

/**
Expand Down Expand Up @@ -325,7 +325,8 @@ export const linkDeviceRoute = _route('linkDevice', {
* ```
*/
export const captchaRoute = _route('captcha', {
patterns: [_pattern('signalcaptcha:', ':captchaId', '', {})],
// needs `(.+)` to capture `.` in hostname
patterns: [_pattern('signalcaptcha:', ':captchaId(.+)', '', {})],
schema: z.object({
captchaId: paramSchema, // opaque
}),
Expand Down

0 comments on commit 31d680d

Please sign in to comment.