diff --git a/recaptcha.go b/recaptcha.go index 64a97ac..bad57b5 100644 --- a/recaptcha.go +++ b/recaptcha.go @@ -19,8 +19,8 @@ const ( V2 VERSION = iota // V3 recaptcha api v3, more details can be found here : https://developers.google.com/recaptcha/docs/v3 V3 - // DefaultTreshold Default minimin score when using V3 api - DefaultTreshold float32 = 0.5 + // DefaultThreshold Default minimin score when using V3 api + DefaultThreshold float32 = 0.5 ) type reCHAPTCHARequest struct { @@ -100,7 +100,7 @@ type VerifyOption struct { RemoteIP string } -// VerifyWithOptions returns `nil` if no error and the client solved the challenge correctly and all options are natching +// VerifyWithOptions returns `nil` if no error and the client solved the challenge correctly and all options are matching // `Threshold` and `Action` are ignored when using V2 version func (r *ReCAPTCHA) VerifyWithOptions(challengeResponse string, options VerifyOption) error { var body reCHAPTCHARequest @@ -164,8 +164,8 @@ func (r *ReCAPTCHA) confirm(recaptcha reCHAPTCHARequest, options VerifyOption) ( Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, options.Threshold) return } - if options.Threshold == 0 && DefaultTreshold > result.Score { - Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, DefaultTreshold) + if options.Threshold == 0 && DefaultThreshold > result.Score { + Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, DefaultThreshold) return } } diff --git a/recaptcha_test.go b/recaptcha_test.go index 8d1a5cf..142a663 100644 --- a/recaptcha_test.go +++ b/recaptcha_test.go @@ -358,10 +358,10 @@ func (s *ReCaptchaSuite) TestV3VerifyWithActionOption(c *C) { } -type mockV3SuccessClientWithTresholdOption struct{} -type mockV3FailClientWithTresholdOption struct{} +type mockV3SuccessClientWithThresholdOption struct{} +type mockV3FailClientWithThresholdOption struct{} -func (*mockV3SuccessClientWithTresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) { +func (*mockV3SuccessClientWithThresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) { resp = &http.Response{ Status: "200 OK", StatusCode: 200, @@ -375,7 +375,7 @@ func (*mockV3SuccessClientWithTresholdOption) PostForm(url string, formValues ur `)) return } -func (*mockV3FailClientWithTresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) { +func (*mockV3FailClientWithThresholdOption) PostForm(url string, formValues url.Values) (resp *http.Response, err error) { resp = &http.Response{ Status: "200 OK", StatusCode: 200, @@ -389,16 +389,16 @@ func (*mockV3FailClientWithTresholdOption) PostForm(url string, formValues url.V `)) return } -func (s *ReCaptchaSuite) TestV3VerifyWithTresholdOption(c *C) { +func (s *ReCaptchaSuite) TestV3VerifyWithThresholdOption(c *C) { captcha := ReCAPTCHA{ - client: &mockV3SuccessClientWithTresholdOption{}, + client: &mockV3SuccessClientWithThresholdOption{}, Version: V3, } err := captcha.VerifyWithOptions("mycode", VerifyOption{Threshold: 0.6}) c.Assert(err, IsNil) - captcha.client = &mockV3FailClientWithTresholdOption{} + captcha.client = &mockV3FailClientWithThresholdOption{} err = captcha.VerifyWithOptions("mycode", VerifyOption{Threshold: 0.6}) c.Assert(err, NotNil) c.Check(err, ErrorMatches, "received score '0.230000', while expecting minimum '0.600000'") @@ -426,7 +426,7 @@ func (*mockV2SuccessClientWithV3IgnoreOptions) PostForm(url string, formValues u } func (s *ReCaptchaSuite) TestV2VerifyWithV3IgnoreOptions(c *C) { captcha := ReCAPTCHA{ - client: &mockV3SuccessClientWithTresholdOption{}, + client: &mockV3SuccessClientWithThresholdOption{}, Version: V2, } err := captcha.VerifyWithOptions("mycode", VerifyOption{Action: "homepage", Threshold: 0.5})