From ec843ce92ccfecfad78b62642f37a14f192cd744 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 9 Feb 2021 23:59:36 +0900 Subject: [PATCH] internal/web: Consider the case when navigator exists but userAgent doesn't This can happen on go2cpp. --- internal/web/web_js.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/web/web_js.go b/internal/web/web_js.go index 793107a50..2c5edff3d 100644 --- a/internal/web/web_js.go +++ b/internal/web/web_js.go @@ -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") }