From 57d493a5491e5265aa4c198c9ae0fc9a32af23a6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 17 Jun 2019 10:56:50 +0900 Subject: [PATCH] web: Optimization: Cache user agent value --- internal/web/js.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/web/js.go b/internal/web/js.go index 2e7652e56..16b565784 100644 --- a/internal/web/js.go +++ b/internal/web/js.go @@ -30,20 +30,20 @@ func IsBrowser() bool { return true } +var userAgent = js.Global().Get("navigator").Get("userAgent").String() + func IsIOSSafari() bool { - ua := js.Global().Get("navigator").Get("userAgent").String() - if !strings.Contains(ua, "iPhone") { + if !strings.Contains(userAgent, "iPhone") { return false } return true } func IsAndroidChrome() bool { - ua := js.Global().Get("navigator").Get("userAgent").String() - if !strings.Contains(ua, "Android") { + if !strings.Contains(userAgent, "Android") { return false } - if !strings.Contains(ua, "Chrome") { + if !strings.Contains(userAgent, "Chrome") { return false } return true