diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index c1f9ff1c..faeecc9a 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1 @@ -- Fix: preselect in ruleWithContext (#630) +- Fix: avoid modify ruleName epl if already unique (#654) diff --git a/lib/models/rules.js b/lib/models/rules.js index 15382735..397e0a3e 100644 --- a/lib/models/rules.js +++ b/lib/models/rules.js @@ -91,7 +91,10 @@ function postR2core(rule, callback) { eplRule = {}; if (isTimedRule(rule)) { // Ensure ruleName in EPL text is in unique format: rule.name@service+subservice - rule.text = rule.text.replace(rule.name, myutils.ruleUniqueName(rule)); + const uniqueNameRule = myutils.ruleUniqueName(rule); + if (!rule.text.includes(uniqueNameRule)) { + rule.text = rule.text.replace(rule.name, uniqueNameRule); + } context = { name: myutils.contextNameTimedRule(rule), text: myutils.contextEPLTimedRule(rule) @@ -175,7 +178,10 @@ function putR2core(rules, callback) { if (rule.text) { if (isTimedRule(rule)) { // Ensure ruleName in EPL text is in unique format: rule.name@service+subservice - rule.text = rule.text.replace(rule.name, myutils.ruleUniqueName(rule)); + const uniqueNameRule = myutils.ruleUniqueName(rule); + if (!rule.text.includes(uniqueNameRule)) { + rule.text = rule.text.replace(rule.name, uniqueNameRule); + } rulesAndContexts.push({ name: myutils.contextNameTimedRule(rule), text: myutils.contextEPLTimedRule(rule)