fix: CAPTCHA ERROR cause by Undefined UA

This commit is contained in:
Roi Feng
2025-03-20 16:16:53 -04:00
parent dfce050dd9
commit 9f218a45bb

View File

@ -3,10 +3,14 @@ package utils
import ( import (
"fmt" "fmt"
"github.com/mssola/useragent" "github.com/mssola/useragent"
"regexp"
) )
func GetClearanceUserAgent(inputUA string) string { func GetClearanceUserAgent(inputUA string) string {
if len(inputUA) < 8 || inputUA[:8] != "Mozilla/" { if len(inputUA) < 8 || inputUA[:8] != "Mozilla/" {
if inputUA == "" || regexp.MustCompile(`^\s*$`).MatchString(inputUA) {
return "undefined"
}
return inputUA return inputUA
} }