From 4d705fdc2bbbefa7a39fc6cfc55609b7c3affe24 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 3 Dec 2024 11:27:49 +0000 Subject: [PATCH] fix: parse Chrome instead of Android as browser (#1575) --- src/__tests__/utils/event-utils.test.ts | 6 +++--- src/utils/user-agent-utils.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/__tests__/utils/event-utils.test.ts b/src/__tests__/utils/event-utils.test.ts index 09b75c2b0..973d9238d 100644 --- a/src/__tests__/utils/event-utils.test.ts +++ b/src/__tests__/utils/event-utils.test.ts @@ -229,11 +229,11 @@ describe(`event-utils`, () => { expectedBrowser: 'Android Mobile', }, { - name: 'Android Browser on Galaxy S3', + name: 'Chrome Browser on Galaxy S3', userAgent: 'Mozilla/5.0 (Linux; Android 4.4.4; en-us; SAMSUNG GT-I9300I Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36', - expectedVersion: 4.4, - expectedBrowser: 'Android Mobile', + expectedVersion: 28.0, + expectedBrowser: 'Chrome', }, ] diff --git a/src/utils/user-agent-utils.ts b/src/utils/user-agent-utils.ts index 7ba95c034..bd91213fa 100644 --- a/src/utils/user-agent-utils.ts +++ b/src/utils/user-agent-utils.ts @@ -113,10 +113,10 @@ export const detectBrowser = function (user_agent: string, vendor: string | unde return CHROME_IOS // why not just Chrome? } else if (includes(user_agent, 'CrMo')) { return CHROME - } else if (includes(user_agent, ANDROID) && includes(user_agent, SAFARI)) { - return ANDROID_MOBILE } else if (includes(user_agent, CHROME)) { return CHROME + } else if (includes(user_agent, ANDROID) && includes(user_agent, SAFARI)) { + return ANDROID_MOBILE } else if (includes(user_agent, 'FxiOS')) { return FIREFOX_IOS } else if (includes(user_agent.toLowerCase(), KONQUEROR.toLowerCase())) {