Skip to content

Commit 92c1436

Browse files
fioneraclaude
andcommitted
refactor: resolve captcha verify URLs with a switch
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent afae4fd commit 92c1436

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

validator_captcha.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ import (
1212
type captchaValidator struct {
1313
}
1414

15-
var captchaVerifyURLs = map[ValidationType]string{
16-
ValidationTypeTurnstile: "https://challenges.cloudflare.com/turnstile/v0/siteverify",
17-
ValidationTypeHCaptcha: "https://api.hcaptcha.com/siteverify",
18-
ValidationTypeReCaptcha: "https://www.google.com/recaptcha/api/siteverify",
15+
func captchaVerifyURL(t ValidationType) string {
16+
switch t {
17+
case ValidationTypeTurnstile:
18+
return "https://challenges.cloudflare.com/turnstile/v0/siteverify"
19+
case ValidationTypeHCaptcha:
20+
return "https://api.hcaptcha.com/siteverify"
21+
case ValidationTypeReCaptcha:
22+
return "https://www.google.com/recaptcha/api/siteverify"
23+
default:
24+
return ""
25+
}
1926
}
2027

2128
// Providers accept tokens of a few kilobytes; reCAPTCHA tokens are the
@@ -77,7 +84,7 @@ func (captchaValidator) isValid(b *Berghain, req *ValidatorRequest, _ *Validator
7784

7885
verifyURL := lc.CaptchaVerifyURL
7986
if verifyURL == "" {
80-
verifyURL = captchaVerifyURLs[lc.Type]
87+
verifyURL = captchaVerifyURL(lc.Type)
8188
}
8289

8390
form := url.Values{

0 commit comments

Comments
 (0)