bidi icon indicating copy to clipboard operation
bidi copied to clipboard

->Alternates with similar prefixes is broken

Open davesann opened this issue 11 years ago • 2 comments

(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

davesann avatar May 25 '14 04:05 davesann

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

davesann avatar May 25 '14 04:05 davesann

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.

KaliszAd avatar Mar 24 '22 11:03 KaliszAd