diff --git a/src/controller/utils/scenarios.ts b/src/controller/utils/scenarios.ts index d9986c595..117d5a0a2 100644 --- a/src/controller/utils/scenarios.ts +++ b/src/controller/utils/scenarios.ts @@ -21,6 +21,13 @@ export type ScenariosOptions = { } export default async function (options: ScenariosOptions) { + /** + * Replace 'asterisk' with '*' due to parsing problems + */ + options.hosting = check.isArray(options.hosting) + ? options.hosting.map(hosting => (hosting === 'asterisk' ? ASTERISK : hosting)) + : options.hosting + /** * Graph */ @@ -113,8 +120,11 @@ function matches(graph: Graph, input: string[], hosting: string[]): boolean { // Accept that user provided hosting is shorter than rule if (check.isUndefined(is)) return true + if (asterisk) return matches(graph, utils.copy(input), utils.copy(hosting)) + if (graph.inheritance.isNodeType(is, question)) { const hostingCopy = utils.copy(hosting) + if (asterisk) hostingCopy.shift() hostingCopy.shift() @@ -123,7 +133,5 @@ function matches(graph: Graph, input: string[], hosting: string[]): boolean { return matches(graph, utils.copy(input), hostingCopy) } - if (asterisk) return matches(graph, utils.copy(input), utils.copy(hosting)) - return false }