Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix asterisk parsing #421

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading