Skip to content

Commit

Permalink
LYNX-759: Fix for copy-pasted rules containing whitespaces characters
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4de committed Feb 13, 2025
1 parent e0bb70e commit 1f023ad
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions blocks/targeted-block/condition-matcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function rulesMatched(activeRules, rules) {
return activeRules && rules.some((rule) => activeRules.includes(rule));
return activeRules && rules.some((rule) => activeRules.includes(rule.trim()));
}

const groupMatched = (activeGroup, groups) => groups.includes(activeGroup);
Expand All @@ -13,14 +13,14 @@ export default function conditionsMatched(activeRules, blockConfig) {
} = blockConfig;

const activeSegments = activeRules.customerSegments?.map(
(segment) => segment.name,
(segment) => segment.name.trim(),
);
const activeGroup = activeRules.customerGroup?.name;
const activeGroup = activeRules.customerGroup?.name.trim();
const activeCartRules = activeRules.cart?.map(
(rule) => rule.name,
(rule) => rule.name.trim(),
);
const activePriceRules = activeRules.catalogPriceRules?.rules?.map(
(rule) => rule.name,
(rule) => rule.name.trim(),
);

if (customerSegments !== undefined && !rulesMatched(activeSegments, customerSegments.split(','))) {
Expand Down

0 comments on commit 1f023ad

Please sign in to comment.