Skip to content

Commit

Permalink
handle exception when trying to access cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Feb 26, 2024
1 parent 470903b commit 5d2257c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion peachjam/js/peachjam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ class PeachJam {
// if window.dataLayer is not set, then Google Analytics is not enabled, but there may be cookies still set; clear them
// @ts-ignore
if (!window.dataLayer) {
const cookies = document.cookie.split(';');
let cookies = [];
try {
cookies = document.cookie.split(';');
} catch {
// ignore security errors when reading cookies
return;
}
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i];
const eqPos = cookie.indexOf('=');
Expand Down

0 comments on commit 5d2257c

Please sign in to comment.