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.
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.