Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix value between optional parameters without values not visible (#64550)

Mahatthana (Kelvin) Nomsawadi27d6352a938a
diff --git a/src/metabase/parameters/shared.cljc b/src/metabase/parameters/shared.cljc
index 7c2a0abd4ae..7131450ca2b 100644
--- a/src/metabase/parameters/shared.cljc
+++ b/src/metabase/parameters/shared.cljc
@@ -281,7 +281,7 @@
split-text))
(def ^:private optional-block-regex
- #"\[\[.+\]\]")
+ #"\[\[.+?\]\]")
(def ^:private non-optional-block-regex
#"\[\[(.+?)\]\]")
diff --git a/test/metabase/parameters/shared_test.cljc b/test/metabase/parameters/shared_test.cljc
index 5655abd2aa8..7aff3893cf7 100644
--- a/test/metabase/parameters/shared_test.cljc
+++ b/test/metabase/parameters/shared_test.cljc
@@ -354,6 +354,11 @@
{"foo" {:type :string/= :value "foo"}}
"foofoo"
+ ;; Make sure we handle multiple optional blocks without values correctly. This has to do with regex greediness.
+ "[[{{foo}}]] between [[{{bar}}]]"
+ {}
+ " between "
+
"[[{{foo}}]] [[{{bar}}]]"
{"foo" {:type :string/= :value 1} "bar" {:type :string/= :value 2}}
"1 2"