Fix handling of trailing '/' in captcha urls

This commit is contained in:
Fedor Indutny 2023-12-06 01:35:38 +01:00 committed by GitHub
parent e41973c238
commit f152dcccc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -119,6 +119,17 @@ describe('signalRoutes', () => {
check(`signalcaptcha://${captchaId}`, result);
});
it('captcha with a trailing slash', () => {
const captchaId =
'signal-hcaptcha.Foo-bAr_baz.challenge.fOo-bAR_baZ.fOO-BaR_baz';
const result: ParsedSignalRoute = {
key: 'captcha',
args: { captchaId },
};
const check = createCheck({ hasWebUrl: false });
check(`signalcaptcha://${captchaId}/`, result);
});
it('linkCall', () => {
const result: ParsedSignalRoute = {
key: 'linkCall',

View file

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