Skip to content

Commit 2393f51

Browse files
committed
Fix invalid access to navigator.
GitOrigin-RevId: 42653efd6af149b2f1a7c43e0d160e95c74e5805
1 parent 6b4c883 commit 2393f51

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ui/Browser.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ const maybeWindow =
77
typeof window === 'undefined'
88
? {
99
HTMLElement: false,
10-
navigator: { userAgent: '' },
10+
navigator: { maxTouchPoints: 0, userAgent: '' },
1111
safari: null,
1212
}
1313
: window;
1414

15-
export const isIPhone = /iphone/i.test(maybeWindow.navigator.userAgent);
15+
const navigator = maybeWindow.navigator;
16+
17+
export const isIPhone = /iphone/i.test(navigator.userAgent);
1618

1719
export const isIOS =
18-
!!maybeWindow.navigator.userAgent.match(/i(?:pad|phone)/i) ||
20+
!!navigator.userAgent.match(/i(?:pad|phone)/i) ||
1921
(/(macintosh|macintel|macppc|mac68k|macos)/i.test(navigator.userAgent) &&
2022
navigator.maxTouchPoints > 0);
2123

0 commit comments

Comments
 (0)