From 375840432a1792f25d0677f4f7ae4a18bc8eaf6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Tue, 19 Mar 2024 17:50:39 +0100 Subject: [PATCH] fix: unhandled exception when invalid category is passed to `acceptedCategory` The small change prevents passing undefined to a function that expects an Array by providing a fallback. --- src/core/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/api.js b/src/core/api.js index 0c607daf..45911b1c 100644 --- a/src/core/api.js +++ b/src/core/api.js @@ -129,7 +129,7 @@ export const acceptService = (service, category) => { */ export const acceptedService = (service, category) => { const acceptedServices = !globalObj._state._invalidConsent - ? globalObj._state._acceptedServices[category] + ? (globalObj._state._acceptedServices[category] || []) : []; return elContains(acceptedServices, service);