Skip to content

Commit da410ad

Browse files
committed
perf: extract Apple platform regex
1 parent ab1e8ae commit da410ad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/composables/usePlatformModifierKey.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const APPLE_PLATFORM_RE = /Mac|iPhone|iPad|iPod/i
2+
13
function detectApplePlatform() {
24
if (!import.meta.client) return false
35

@@ -10,7 +12,7 @@ function detectApplePlatform() {
1012
const platform = nav.userAgentData?.platform ?? nav.platform ?? ''
1113
const userAgent = navigator.userAgent ?? ''
1214

13-
return /Mac|iPhone|iPad|iPod/i.test(platform) || /Mac|iPhone|iPad|iPod/i.test(userAgent)
15+
return APPLE_PLATFORM_RE.test(platform) || APPLE_PLATFORM_RE.test(userAgent)
1416
}
1517

1618
export function usePlatformModifierKey() {

0 commit comments

Comments
 (0)