From 4ff6108d1a4e8bc662ef3a2cd01761e3afb721f8 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 23 May 2024 00:51:52 -0400 Subject: [PATCH] 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 --- lib/floe/workflow/choice_rule/matches.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/floe/workflow/choice_rule/matches.rb b/lib/floe/workflow/choice_rule/matches.rb index 3b5c8e1b..3e0cbb49 100644 --- a/lib/floe/workflow/choice_rule/matches.rb +++ b/lib/floe/workflow/choice_rule/matches.rb @@ -4,16 +4,10 @@ module Floe class Workflow class ChoiceRule class Matches < Floe::Workflow::ChoiceRule - def initialize(payload, *, **) - super - # NOTE: only StringMatches exists (so no Path option) - # Since this is static, we're converting it up front - @ref = Regexp.escape(@ref).gsub('\*', '.*?') - end - def true?(context, input) lhs = variable_value(context, input) - valid?(lhs) && lhs.match?(ref) + rhs = compare_value(context, input) + valid?(lhs) && lhs.match?(Regexp.escape(rhs).gsub('\*', '.*?')) end end end