mirror of
https://github.com/metosin/reitit.git
synced 2025-12-23 18:41:11 +00:00
Merge pull request #466 from metosin/feature/space-as-separator
Allow space as separator, fixes #411
This commit is contained in:
commit
eb10af92c4
2 changed files with 12 additions and 3 deletions
|
|
@ -167,7 +167,7 @@
|
||||||
(instance? CatchAll path)
|
(instance? CatchAll path)
|
||||||
(assoc-in node [:catch-all path] (-node {:params params, :data data}))
|
(assoc-in node [:catch-all path] (-node {:params params, :data data}))
|
||||||
|
|
||||||
(str/blank? path)
|
(empty? path)
|
||||||
(-insert node ps fp params data)
|
(-insert node ps fp params data)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
|
@ -439,7 +439,9 @@
|
||||||
["/v1/topics" 54]
|
["/v1/topics" 54]
|
||||||
["/v1/orgs" 55]
|
["/v1/orgs" 55]
|
||||||
["/v1/users/:user-id/bookmarks" 56]
|
["/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)
|
(insert)
|
||||||
(compile)
|
(compile)
|
||||||
(pretty)))
|
(pretty)))
|
||||||
|
|
|
||||||
|
|
@ -121,4 +121,11 @@
|
||||||
(trie/compile)
|
(trie/compile)
|
||||||
(trie/path-matcher)) "/a")]
|
(trie/path-matcher)) "/a")]
|
||||||
(is (record? (:params match)))
|
(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")))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue