Skip to content

Commit 07a1411

Browse files
committed
escape Matches' value at runtime
Since the string is static, we can escape at initialization time But Matches may end up with MatchesPath or something. So Just escaping at runtime
1 parent 82bdec3 commit 07a1411

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/floe/workflow/choice_rule/matches.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ module Floe
44
class Workflow
55
class ChoiceRule
66
class Matches < Floe::Workflow::ChoiceRule
7-
def initialize(payload, *, **)
8-
super
9-
# NOTE: only StringMatches exists (so no Path option)
10-
# Since this is static, we're converting it up front
11-
@ref = Regexp.escape(@ref).gsub('\*', '.*?')
12-
end
13-
147
def true?(context, input)
158
lhs = variable_value(context, input)
16-
valid?(lhs) && lhs.match?(ref)
9+
rhs = compare_value(context, input)
10+
valid?(lhs) && lhs.match?(Regexp.escape(rhs).gsub('\*', '.*?'))
1711
end
1812
end
1913
end

0 commit comments

Comments
 (0)