internal/web: Consider the case when navigator exists but userAgent doesn't

This can happen on go2cpp.
This commit is contained in:
Hajime Hoshi 2021-02-09 23:59:36 +09:00
parent 0b30ed5959
commit ec843ce92c

View File

@ -33,7 +33,11 @@ func init() {
if !nav.Truthy() {
return
}
userAgent := nav.Get("userAgent").String()
ua := nav.Get("userAgent")
if !ua.Truthy() {
return
}
userAgent := ua.String()
isIOSSafari = strings.Contains(userAgent, "iPhone") || strings.Contains(userAgent, "iPad")
isAndroidChrome = strings.Contains(userAgent, "Android") && strings.Contains(userAgent, "Chrome")
}