@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.
@@ -665,7 +665,15 @@ var getDefaultsFromCookie = function () {
665
665
  if (typeof document === 'undefined') {
666
666
  return;
667
667
  }
668
- var match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
668
+ var match;
669
+ try {
670
+ match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
671
+ }
672
+ catch (e) {
673
+ // Some environments such as Angular Universal SSR have a
674
+ // `document` object but error on accessing `document.cookie`.
675
+ return;
676
+ }
669
677
  var decoded = match && base64Decode(match[1]);
670
678
  return decoded && JSON.parse(decoded);
671
679
  };
@@ -676,9 +684,21 @@ var getDefaultsFromCookie = function () {
676
684
  * (3) if such an object exists in a cookie
677
685
  */
678
686
  var getDefaults = function () {
679
- return getDefaultsFromGlobal() ||
680
- getDefaultsFromEnvVariable() ||
681
- getDefaultsFromCookie();
687
+ try {
688
+ return (getDefaultsFromGlobal() ||
689
+ getDefaultsFromEnvVariable() ||
690
+ getDefaultsFromCookie());
691
+ }
692
+ catch (e) {
693
+ /**
694
+ * Catch-all for being unable to get __FIREBASE_DEFAULTS__ due
695
+ * to any environment case we have not accounted for. Log to
696
+ * info instead of swallowing so we can find these unknown cases
697
+ * and add paths for them if needed.
698
+ */
699
+ console.info("Unable to get __FIREBASE_DEFAULTS__ due to: " + e);
700
+ return;
701
+ }
682
702
  };
683
703
  /**
684
704
  * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object