diff --git a/modules/reitit-core/java-src/reitit/Trie.java b/modules/reitit-core/java-src/reitit/Trie.java index 7befcc3a..65f98a42 100644 --- a/modules/reitit-core/java-src/reitit/Trie.java +++ b/modules/reitit-core/java-src/reitit/Trie.java @@ -211,7 +211,7 @@ public class Trie { @Override public Match match(int i, int max, char[] path) { - if (i < max) { + if (i <= max) { return new Match(params.assoc(parameter, decode(path, i, max)), data); } return null; diff --git a/modules/reitit-core/src/reitit/trie.cljc b/modules/reitit-core/src/reitit/trie.cljc index 089a7628..a6ba6251 100644 --- a/modules/reitit-core/src/reitit/trie.cljc +++ b/modules/reitit-core/src/reitit/trie.cljc @@ -240,7 +240,7 @@ (let [match (->Match params data)] (reify Matcher (match [_ i max path] - (if (< i max) (assoc-param match key (decode path i max true)))) + (if (<= i max) (assoc-param match key (decode path i max true)))) (view [_] [key [data]]) (depth [_] 1) (length [_])))) diff --git a/test/cljc/reitit/core_test.cljc b/test/cljc/reitit/core_test.cljc index cc91149d..c48f6348 100644 --- a/test/cljc/reitit/core_test.cljc +++ b/test/cljc/reitit/core_test.cljc @@ -87,6 +87,7 @@ (is (= ::boo (by-path "/abba/1/boo"))) (is (= ::baa (by-path "/abba/dabba/boo/baa"))) (is (= ::boo (by-path "/abba/dabba/boo"))) + (is (= ::wild (by-path "/olipa/kerran/avaruus/vaan/"))) (is (= ::wild (by-path "/olipa/kerran/avaruus/vaan/ei/toista/kertaa"))))) (testing "bracket-params" @@ -387,5 +388,10 @@ (let [router (r/router [["/" :root] ["/" {:name :create :method :post}]] - {:conflicts nil})] - (is (= :root (-> (r/match-by-path router "/") :data :name))))) \ No newline at end of file + {:conflicts nil}) + router2 (r/router + [["/*a" :root] + ["/:a/b/c/d" {:name :create :method :post}]] + {:conflicts nil})] + (is (= :root (-> (r/match-by-path router "/") :data :name))) + (is (= :root (-> (r/match-by-path router2 "/") :data :name)))))