@firebase/util 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -661,7 +661,15 @@ var getDefaultsFromCookie = function () {
661
661
  if (typeof document === 'undefined') {
662
662
  return;
663
663
  }
664
- var match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
664
+ var match;
665
+ try {
666
+ match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
667
+ }
668
+ catch (e) {
669
+ // Some environments such as Angular Universal SSR have a
670
+ // `document` object but error on accessing `document.cookie`.
671
+ return;
672
+ }
665
673
  var decoded = match && base64Decode(match[1]);
666
674
  return decoded && JSON.parse(decoded);
667
675
  };
@@ -672,9 +680,21 @@ var getDefaultsFromCookie = function () {
672
680
  * (3) if such an object exists in a cookie
673
681
  */
674
682
  var getDefaults = function () {
675
- return getDefaultsFromGlobal() ||
676
- getDefaultsFromEnvVariable() ||
677
- getDefaultsFromCookie();
683
+ try {
684
+ return (getDefaultsFromGlobal() ||
685
+ getDefaultsFromEnvVariable() ||
686
+ getDefaultsFromCookie());
687
+ }
688
+ catch (e) {
689
+ /**
690
+ * Catch-all for being unable to get __FIREBASE_DEFAULTS__ due
691
+ * to any environment case we have not accounted for. Log to
692
+ * info instead of swallowing so we can find these unknown cases
693
+ * and add paths for them if needed.
694
+ */
695
+ console.info("Unable to get __FIREBASE_DEFAULTS__ due to: " + e);
696
+ return;
697
+ }
678
698
  };
679
699
  /**
680
700
  * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object