From d7b656e884546d1b498db2b2a476df1254f978b4 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Sun, 3 Oct 2021 13:01:48 -0300 Subject: Fix issue with regex parsing --- README.md | 4 ++++ project.clj | 2 +- src/ruuter/core.cljc | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a6d4180..d9d14dd 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,10 @@ What the actual map can contain that you return depends again on the HTTP server ## Changelog +### 1.2.1 + +- Fixed an issue with regex parsing. Sorry about that. + ### 1.2.0 - Implemented optional route parameters, so now you can do paths like `/hi/:name?` in your routes, and it would match the route even if the `:name` is not present. All you have to do is add a question mark to the parameter, and that's it. diff --git a/project.clj b/project.clj index 7674f4e..487dc9b 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.clojars.askonomm/ruuter "1.2.0" +(defproject org.clojars.askonomm/ruuter "1.2.1" :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 0da46b6..8052d36 100644 --- a/src/ruuter/core.cljc +++ b/src/ruuter/core.cljc @@ -24,8 +24,7 @@ :else ; what comes around, goes around %)) - (string/join "\\/") - (re-pattern)))) + (string/join "\\/")))) (defn- path+uri->path-params @@ -62,7 +61,7 @@ (let [route (->> routes (filter #(not (= :not-found (:path %)))) (map #(merge % {:regex-path (path->regex-path (:path %))})) - (filter #(and (re-matches (:regex-path %) uri) + (filter #(and (re-matches (re-pattern (:regex-path %)) uri) (= (:method %) request-method))) first)] (when route -- cgit v1.2.3