Skip to content

Commit

Permalink
Fix invalid access to navigator.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 42653efd6af149b2f1a7c43e0d160e95c74e5805
  • Loading branch information
cpojer committed May 15, 2024
1 parent 6b4c883 commit 2393f51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/Browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ const maybeWindow =
typeof window === 'undefined'
? {
HTMLElement: false,
navigator: { userAgent: '' },
navigator: { maxTouchPoints: 0, userAgent: '' },
safari: null,
}
: window;

export const isIPhone = /iphone/i.test(maybeWindow.navigator.userAgent);
const navigator = maybeWindow.navigator;

export const isIPhone = /iphone/i.test(navigator.userAgent);

export const isIOS =
!!maybeWindow.navigator.userAgent.match(/i(?:pad|phone)/i) ||
!!navigator.userAgent.match(/i(?:pad|phone)/i) ||
(/(macintosh|macintel|macppc|mac68k|macos)/i.test(navigator.userAgent) &&
navigator.maxTouchPoints > 0);

Expand Down

0 comments on commit 2393f51

Please sign in to comment.