refactor(views/login): simplify userAgent matching

- there is no need to have the Regexp check done
in 2 separate tests – just do it once
- I also have ordered the userAgents by order of
"popularity", so (in theory) it should match faster
for most people this way
(although realistically you will not notice this at all)
This commit is contained in:
Panagiotis Papadopoulos 2025-01-07 08:37:37 +01:00
parent b44397a6bf
commit 15faf161b5

View File

@ -66,9 +66,8 @@
if (mQ?.media === '(pointer:coarse)') return !!mQ.matches;
if ('orientation' in window) return true;
return /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(navigator.userAgent) ||
/\b(Android|Windows Phone|iPad|iPod)\b/i.test(navigator.userAgent);
const userAgentsRegEx = /\b(Android|iPhone|iPad|iPod|Windows Phone|BlackBerry|webOS|IEMobile)\b/i
return userAgentsRegEx.test(navigator.userAgent)
}
</script>