[automation] Allow dashes in rule file names (#1750)

* Allow dashes in rule file names

Fixes #1728

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2020-10-25 20:19:00 +01:00 committed by GitHub
parent 3df4403268
commit 749b8f17fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,10 +87,10 @@ public class DSLScriptEngine implements javax.script.ScriptEngine {
if (script.stripLeading().startsWith(DSLScriptContextProvider.CONTEXT_IDENTIFIER)) {
String contextString = script.stripLeading().substring(
DSLScriptContextProvider.CONTEXT_IDENTIFIER.length(), script.stripLeading().indexOf('\n'));
String[] segments = contextString.split("-");
if (segments.length == 2) {
modelName = segments[0];
String ruleIndex = segments[1];
if (contextString.contains("-")) {
int indexLastDash = contextString.lastIndexOf('-');
modelName = contextString.substring(0, indexLastDash);
String ruleIndex = contextString.substring(indexLastDash + 1);
if (contextProvider != null) {
DSLScriptContextProvider cp = contextProvider;
logger.debug("Script uses context '{}'.", contextString);