Skip to content

Commit

Permalink
fix asterisk parsing (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner committed Sep 27, 2024
1 parent 4345ec4 commit e524c64
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/controller/utils/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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()

Expand All @@ -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
}

0 comments on commit e524c64

Please sign in to comment.