From 5d2257cb593c685b5b5e081e56f9b0b16d8f992e Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Mon, 26 Feb 2024 08:11:25 +0200 Subject: [PATCH] handle exception when trying to access cookies --- peachjam/js/peachjam.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/peachjam/js/peachjam.ts b/peachjam/js/peachjam.ts index 474946c7c..24d9102ef 100644 --- a/peachjam/js/peachjam.ts +++ b/peachjam/js/peachjam.ts @@ -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('=');