diff options
| author | Asko Nõmm <ano@ano.ee> | 2022-10-06 01:11:46 +0300 |
|---|---|---|
| committer | Asko Nõmm <ano@ano.ee> | 2022-10-06 01:11:46 +0300 |
| commit | 60e1f9c8a6b5f343cfc8be2d8bc25018cfe0ddab (patch) | |
| tree | c5f117ffb9f46eb393c7b20c5cef0d48ddb0dbe2 | |
| parent | 9e8abbf26d4422ba133bba7186363bee5b1f38d7 (diff) | |
1.3.2
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | project.clj | 2 | ||||
| -rw-r--r-- | src/ruuter/core.cljc | 4 | ||||
| -rw-r--r-- | test/ruuter/core_test.cljc | 6 |
4 files changed, 16 insertions, 6 deletions
@@ -103,7 +103,7 @@ You can also use Ruuter with [Babashka](https://github.com/babashka/babashka), b ### Creating routes -Like mentioned above, each route is a map inside of a vector - the order is important only in that the route matcher will return the first result it finds according to `:path`. +Like mentioned above, each route is a map inside a vector - the order is important only in that the route matcher will return the first result it finds according to `:path`. Each route consists of three items: @@ -161,6 +161,14 @@ What the actual map can contain that you return depends again on the HTTP server ## Changelog +### 1.3.2 + +- When using wildcard parameters, the keyword returned in ´:params´ of a request was ´:name*´, but aiming for consistency with an optional parameter where we remove the question mark ´?´, the asterisk has been removed. + +### 1.3.1 + +- A small bugfix related to wildcard parameters losing the first character in the result. + ### 1.3.0 - Fixed an issue with optional parameters not matching correctly when there were multiple optional paremeters in use. diff --git a/project.clj b/project.clj index 29f048e..8f314b4 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.clojars.askonomm/ruuter "1.3.0" +(defproject org.clojars.askonomm/ruuter "1.3.2" :description "A tiny HTTP router" :url "https://github.com/askonomm/ruuter" :license {:name "MIT" diff --git a/src/ruuter/core.cljc b/src/ruuter/core.cljc index 6eaa912..ec382ec 100644 --- a/src/ruuter/core.cljc +++ b/src/ruuter/core.cljc @@ -42,8 +42,10 @@ (re-find #"\*" path) (let [index-of-k-start (string/index-of path ":") k (-> (subs path (+ 1 index-of-k-start)) + drop-last + string/join keyword) - v (subs uri (+ 1 index-of-k-start))] + v (subs uri index-of-k-start)] {k v}) :else diff --git a/test/ruuter/core_test.cljc b/test/ruuter/core_test.cljc index 75a71a0..1164124 100644 --- a/test/ruuter/core_test.cljc +++ b/test/ruuter/core_test.cljc @@ -27,10 +27,10 @@ :why "because"} (testfn "hello/:who?/:why?" "/hello/world/because"))) (is (= {:who "world"} - (testfn "hello/:who?/:why?" "/hello/world")))) + (testfn "/hello/:who?/:why?" "/hello/world")))) (testing "Wildcard param" - (is (= {:everything* "this/means/literally/everything"} - (testfn "hello/:everything*" "/hello/this/means/literally/everything")))))) + (is (= {:everything "this/means/literally/everything"} + (testfn "/hello/:everything*" "/hello/this/means/literally/everything")))))) (deftest match-route-test (let [testfn #'ruuter/match-route] |
