Skip to content

Commit

Permalink
fix: correctly identify empty cookie value | fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
pboeder committed Mar 15, 2023
1 parent db7da86 commit c3c3a66
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ export class CookieConsentBanner {
.filter((category) => category.isMandatory)
.map((category) => category.key);

const cookieValueString =
`; ${document.cookie}`.split(`; ${this.cookieName}=`).pop() ??
"".split(";").shift();
let cookieValues: string[] = [];

const cookieValues = cookieValueString ? cookieValueString.split(",") : [];
if (document.cookie) {
const cookieValueString =
`; ${document.cookie}`.split(`; ${this.cookieName}=`).pop() ??
"".split(";").shift();
cookieValues = cookieValueString ? cookieValueString.split(",") : [];
}

if (cookieValues.length === 0) {
this.isShown = true;
Expand Down

0 comments on commit c3c3a66

Please sign in to comment.