cookie-consent icon indicating copy to clipboard operation
cookie-consent copied to clipboard

Handle badly formatted cookie value

Open pufferfish101007 opened this issue 1 year ago • 0 comments

If the cookie cannot be parsed as valid JSON, reset the cookie to a sensible default and return this new value. Adds/updates unit tests to reflect this change. The 'sensible default value' is just { ...defaultConsent, version: COOKIE_VERSION i.e. { consented: false, marketing: false, necessary: true, preferences: false, statistics: false, version: 4 }. This means that the cookie banner will be shown if the cookie is invalid upon page load; I think this makes sense as we don't know if the user has consented or not. Manually tested in chrome 121 and firefox 122; all unit tests pass.

pufferfish101007 avatar Feb 08 '24 12:02 pufferfish101007