diff --git a/modules/reitit-core/src/reitit/trie.cljc b/modules/reitit-core/src/reitit/trie.cljc index bbd1aded..8cb8f792 100644 --- a/modules/reitit-core/src/reitit/trie.cljc +++ b/modules/reitit-core/src/reitit/trie.cljc @@ -167,7 +167,7 @@ (instance? CatchAll path) (assoc-in node [:catch-all path] (-node {:params params, :data data})) - (str/blank? path) + (empty? path) (-insert node ps fp params data) :else @@ -439,7 +439,9 @@ ["/v1/topics" 54] ["/v1/orgs" 55] ["/v1/users/:user-id/bookmarks" 56] - ["/v1/orgs/:org-id/topics" 57]] + ["/v1/orgs/:org-id/topics" 57] + ["/command1 {arg1} {arg2}" ::cmd1] + ["/command2 {arg1} {arg2} {arg3}" ::cmd2]] (insert) (compile) (pretty))) diff --git a/test/cljc/reitit/trie_test.cljc b/test/cljc/reitit/trie_test.cljc index 36ba52e4..983d52d0 100644 --- a/test/cljc/reitit/trie_test.cljc +++ b/test/cljc/reitit/trie_test.cljc @@ -121,4 +121,11 @@ (trie/compile) (trie/path-matcher)) "/a")] (is (record? (:params match))) - (is (= (trie/->Match {:a "a"} {:a 1}) (update match :params (partial into {}))))))) + (is (= (trie/->Match {:a "a"} {:a 1}) (update match :params (partial into {})))))) + + (testing "space as separator" + (is (= (trie/->Match {:arg1 "say" :arg2 "hello"} ::cmd1) + ((-> (trie/insert nil "/command1 {arg1} {arg2}" ::cmd1) + (trie/insert "/command2 {arg1} {arg2} {arg3}" ::cmd2) + (trie/compile) + (trie/path-matcher)) "/command1 say hello")))))