diff --git a/internal/web/js.go b/internal/web/js.go index 1d8b490c0..dbd00592f 100644 --- a/internal/web/js.go +++ b/internal/web/js.go @@ -25,23 +25,31 @@ func IsBrowser() bool { return true } -var userAgent = js.Global().Get("navigator").Get("userAgent").String() +var ( + userAgent = js.Global().Get("navigator").Get("userAgent").String() + + isIOSSafari bool + isAndroidChrome bool +) + +func init() { + isIOSSafari = strings.Contains(userAgent, "iPhone") + + if !strings.Contains(userAgent, "Android") { + isAndroidChrome = false + } + if !strings.Contains(userAgent, "Chrome") { + isAndroidChrome = false + } + isAndroidChrome = true +} func IsIOSSafari() bool { - if !strings.Contains(userAgent, "iPhone") { - return false - } - return true + return isIOSSafari } func IsAndroidChrome() bool { - if !strings.Contains(userAgent, "Android") { - return false - } - if !strings.Contains(userAgent, "Chrome") { - return false - } - return true + return isAndroidChrome } func IsMobileBrowser() bool {