bidi icon indicating copy to clipboard operation
bidi copied to clipboard

Capture group confusion

Open cch1 opened this issue 7 years ago • 0 comments

Why does this not work?

(bidi/match-route ["/" {[[#"-?[0-9]+(\.[0-9]+)?" :lat]
                         "%7C"
                         [#"-?[0-9]+(\.[0-9]+)?" :lng]
                         "%7C"
                         [#"[0-9]+(\.[0-9]+)?" :radius]] {"/b" :geo}}]
                  "/38.0%7C-78.5%7C10.0/b")

=> {:route-params {:lat "38.0", :lng "%7C", :radius ".5"}, :handler :geo}

If I remove the capture groups (and consequently change the regex to disallow valid integers) then it will "work":

(bidi/match-route ["/" {[[#"-?[0-9]+\.[0-9]+" :lat]
                         "%7C"
                         [#"-?[0-9]+\.[0-9]+" :lng]
                         "%7C"
                         [#"[0-9]+\.[0-9]+" :radius]] {"/b" :geo}}]
                  "/38.0%7C-78.5%7C10.0/b")

=> {:route-params {:lat "38.0", :lng "-78.5", :radius "10.0"}, :handler :geo}

cch1 avatar Jan 16 '17 23:01 cch1