Skip to content

Commit 314b1f6

Browse files
dconeybechuanr
authored and
chuanr
committed
firestore: verify DOMException exists before using it in when base64 decoding (#7130)
1 parent 96fb42f commit 314b1f6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/friendly-ads-yell.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/firestore': patch
3+
'firebase': patch
4+
---
5+
6+
Check that DOMException exists before referencing it, to fix react-native, which was broken by https://github.com/firebase/firebase-js-sdk/pull/7019 in v9.17.2.

packages/firestore/src/platform/browser/base64.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export function decodeBase64(encoded: string): string {
2222
try {
2323
return atob(encoded);
2424
} catch (e) {
25-
if (e instanceof DOMException) {
25+
// Check that `DOMException` is defined before using it to avoid
26+
// "ReferenceError: Property 'DOMException' doesn't exist" in react-native.
27+
// (https://github.com/firebase/firebase-js-sdk/issues/7115)
28+
if (typeof DOMException !== 'undefined' && e instanceof DOMException) {
2629
throw new Base64DecodeError('Invalid base64 string: ' + e);
2730
} else {
2831
throw e;

0 commit comments

Comments
 (0)