Skip to content

Commit 090e8bd

Browse files
committed
failsafe JSON parsing
1 parent aed146e commit 090e8bd

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-cookie-guard",
3-
"version": "4.1.5",
3+
"version": "4.1.6",
44
"description": "<p align=\"center\"> <img src=\"logo.jpg\" alt=\"logo\" width=\"400\"> </p>",
55
"main": "index.js",
66
"directories": {

public/scripts.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/scripts.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,16 @@ function toggleBannerDisplay(cookieBanner, cookieButton, showFloatingButton, hid
183183
*/
184184
function setSliders(cookieConsent) {
185185
if (cookieConsent) {
186-
const consentSettings = JSON.parse(cookieConsent);
187-
for (const category in consentSettings) {
188-
const categoryCheckbox = document.getElementById(category);
189-
if (categoryCheckbox) {
190-
categoryCheckbox.checked = consentSettings[category];
186+
try {
187+
const consentSettings = JSON.parse(cookieConsent);
188+
for (const category in consentSettings) {
189+
const categoryCheckbox = document.getElementById(category);
190+
if (categoryCheckbox) {
191+
categoryCheckbox.checked = consentSettings[category];
192+
}
191193
}
194+
} catch (error) {
195+
console.warn('Error parsing cookie consent JSON:', error);
192196
}
193197
}
194198
}

0 commit comments

Comments
 (0)