Skip to content

Commit

Permalink
Fix isSafari() throwing on React Native (fixes #7962) (#7963)
Browse files Browse the repository at this point in the history
In #7929 some logic was added to Firestore to check for the browser being Safari. This new check for isSafari() unexpectedly threw an exception in React Native. This PR fixes the exception by explicitly checking for an object not being undefined before using it.

Fixes #7962
  • Loading branch information
Yonom committed Jan 19, 2024
1 parent 4b5a82e commit 434f841
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-cooks-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/util': patch
---

Fix isSafari() throwing on React Native
1 change: 1 addition & 0 deletions packages/util/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export function isNodeSdk(): boolean {
export function isSafari(): boolean {
return (
!isNode() &&
!!navigator.userAgent &&
navigator.userAgent.includes('Safari') &&
!navigator.userAgent.includes('Chrome')
);
Expand Down

0 comments on commit 434f841

Please sign in to comment.