Skip to content

Commit 3d96bea

Browse files
committed
[fix] unquote string before turning it into regexp
1 parent c4250be commit 3d96bea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/riemann-query.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
first = (arr) -> arr[0]
22
second = (arr) -> arr[1]
3+
last = (arr) -> arr[-1..]
34
count = (arr) -> arr.length
45
sequential = (arr) -> Array.isArray arr
56
remove = (pred, arr) -> (item for item in arr when not pred item)
@@ -8,6 +9,8 @@ isString = (isType "string")
89
isNumber = (isType "number")
910
re_pattern = (str) -> (new RegExp str, "g").toString()
1011
re_seq = (regexp, str) -> str.match regexp
12+
unquote = (str) -> (isString str) and ((first str) is '"' and (last str) is '"') and str[1...-1] or str
13+
identity = (obj) -> obj
1114
list = (items...) -> items
1215
cons = (x, arr) -> new Array x, arr...
1316
join = (sep, arr) -> if arr then arr.join sep else sep.join ""
@@ -80,7 +83,7 @@ ast_regex = (type, terms) ->
8083
[
8184
type
8285
(do -> switch type
83-
when "regex" then re_pattern (antlr_ast pattern)
86+
when "regex" then re_pattern (unquote (antlr_ast pattern))
8487
when "like" then (antlr_ast pattern))
8588
(antlr_ast string)
8689
]

0 commit comments

Comments
 (0)