bidi
bidi copied to clipboard
->Alternates with similar prefixes is broken
(def routes-test
["/" {(->Alternates ["index" "index-x" "index.html" "x-index.html" "index-x.html" "x.html"]) :handler
}])
(bidi/match-route routes-test "/index") => {:handler :handler}
(bidi/match-route routes-test "/index-x") => nil
(bidi/match-route routes-test "/index.html") => nil
(bidi/match-route routes-test "/x.html") => {:handler :handler}
(bidi/match-route routes-test "/x-index.html") => {:handler :handler}
(bidi/match-route routes-test "/index-x.html") => nil
and workaround,
(def routes-test
["/" {(->Alternates [#"index$" "index-x" "index.html" "x-index.html" "index-x.html" "x.html"]) :handler
}])
will work for all above
How do alternates actually work now with common prefix? The documentation is not clear about how to specify the canonical path (useful for path-for) but match any of the routes with common or different prefix to the same handler.