File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,16 @@ parseMatcher =
1616 , test " should parse empty matcher value" <|
1717 \ () ->
1818 Expect . equal ( Just ( Matcher " alertname" Eq " " )) ( Utils . Filter . parseMatcher " alertname=\"\" " )
19+ , test " should unescape quoted matcher value" <|
20+ \ () ->
21+ Expect . equal
22+ ( Just ( Matcher " alertname" Eq " foo\" bar" ))
23+ ( Utils . Filter . parseMatcher " alertname=\" foo\\\" bar\" " )
24+ , test " should unescape backslash matcher value" <|
25+ \ () ->
26+ Expect . equal
27+ ( Just ( Matcher " alertname" Eq " foo\\ bar" ))
28+ ( Utils . Filter . parseMatcher " alertname=\" foo\\\\ bar\" " )
1929 , fuzz ( tuple ( string, string )) " should parse random matcher string" <|
2030 \ ( key, value ) ->
2131 if List . map isNotEmptyTrimmedAlphabetWord [ key, value ] /= [ True , True ] then
@@ -83,4 +93,10 @@ stringifyFilter =
8393 , { key = " baz" , op = RegexMatch , value = " quux.*" }
8494 ]
8595 )
96+ , test " escapes matcher values" <|
97+ \ () ->
98+ Expect . equal " {foo=\" bar\\\" baz\\\\ qux\" }"
99+ ( Utils . Filter . stringifyFilter
100+ [ { key = " foo" , op = Eq , value = " bar\" baz\\ qux" } ]
101+ )
86102 ]
You can’t perform that action at this time.
0 commit comments