Merge pull request #443 from skibe/resource-handler-path-size-fix

Fix resource handler path matching
This commit is contained in:
Tommi Reiman 2020-10-16 11:24:48 +03:00 committed by GitHub
commit 21df83c804
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -221,8 +221,8 @@
handler (if path
(fn [request]
(let [uri (:uri request)]
(if-let [path (if (>= (count uri) path-size) (subs uri path-size))]
(path-or-index-response path uri))))
(if (.startsWith uri path)
(path-or-index-response (subs uri path-size) uri))))
(fn [request]
(let [uri (:uri request)
path (-> request :path-params parameter)]

View file

@ -491,6 +491,8 @@
(testing "not found"
(let [response (app (request "/not-found"))]
(is (= 404 (:status response))))
(let [response (app {:uri "/XXXXX/hello.json" :request-method :get})]
(is (= 404 (:status response)))))
(testing "3-arity"