Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Empty path-parameter matching path-parameter route #181

Closed
jaidetree opened this issue Nov 20, 2018 · 2 comments
Closed

BUG: Empty path-parameter matching path-parameter route #181

jaidetree opened this issue Nov 20, 2018 · 2 comments
Labels

Comments

@jaidetree
Copy link

jaidetree commented Nov 20, 2018

REPRODUCTION

  1. Create a router with a param like /items/:id
  2. Match by path with /items/

EXAMPLE:

(require '[reitit.core :as r])

(def router (r/router [["/items" ::list]
                       ["/items/:id" ::item]]))
;; => #'user/router
(r/match-by-path router "/items")
;; =>
#reitit.core.Match{:template "/items", :data {:name :user/list}, :result nil, :path-params {}, :path "/items"}
(r/match-by-path router "/items/")
;; =>
#reitit.core.Match{:template "/items/:id", :data {:name :user/item}, :result nil, :path-params {:id ""}, :path "/items/"}

EXPECTED

  • The path /items/ should not match the /items/:id path.

ACTUAL

  • The path /items/ matched the /items/:id path and the (:id path-params) is an empty string "".

OTHER NOTES

In the Clojure Slack #reitit channel Ikitomni had tested it against Compojure and bidi. They shared the compojure behavior:

(require '[compojure.core :as c])

((c/GET "/kikka/:id" [] "kikka") {:request-method :get, :uri "/kikka/1"})
; => {:status 200, :headers {"Content-Type" "text/html; charset=utf-8"}, :body "kikka"}

((c/GET "/kikka/:id" [] identity) {:request-method :get, :uri "/kikka/"})
; => nil
@ikitommi
Copy link
Member

Should be fixed in #191.

@jaidetree
Copy link
Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants