mirror of
https://github.com/metosin/reitit.git
synced 2026-02-12 22:35:19 +00:00
Use ensure-path for matching
This commit is contained in:
parent
8d4c591f96
commit
a8d6b32389
1 changed files with 17 additions and 10 deletions
|
|
@ -208,8 +208,13 @@
|
||||||
(match-by-path [_ path]
|
(match-by-path [_ path]
|
||||||
(reduce
|
(reduce
|
||||||
(fn [_ ^Route route]
|
(fn [_ ^Route route]
|
||||||
(if-let [path-params ((:matcher route) path)]
|
(let [slashed-path (ensure-slash path)]
|
||||||
(reduced (->Match (:path route) (:data route) (:result route) (impl/url-decode-coll path-params) path))))
|
(if-let [path-params ((:matcher route) slashed-path)]
|
||||||
|
(reduced (->Match (:path route)
|
||||||
|
(:data route)
|
||||||
|
(:result route)
|
||||||
|
(impl/url-decode-coll path-params)
|
||||||
|
slashed-path)))))
|
||||||
nil pl))
|
nil pl))
|
||||||
(match-by-name [_ name]
|
(match-by-name [_ name]
|
||||||
(if-let [match (impl/fast-get lookup name)]
|
(if-let [match (impl/fast-get lookup name)]
|
||||||
|
|
@ -255,7 +260,7 @@
|
||||||
(route-names [_]
|
(route-names [_]
|
||||||
names)
|
names)
|
||||||
(match-by-path [_ path]
|
(match-by-path [_ path]
|
||||||
(impl/fast-get data path))
|
(impl/fast-get data (ensure-slash path)))
|
||||||
(match-by-name [_ name]
|
(match-by-name [_ name]
|
||||||
(if-let [match (impl/fast-get lookup name)]
|
(if-let [match (impl/fast-get lookup name)]
|
||||||
(match nil)))
|
(match nil)))
|
||||||
|
|
@ -296,10 +301,11 @@
|
||||||
(route-names [_]
|
(route-names [_]
|
||||||
names)
|
names)
|
||||||
(match-by-path [_ path]
|
(match-by-path [_ path]
|
||||||
(if-let [match (segment/lookup pl path)]
|
(let [slashed-path (ensure-slash path)]
|
||||||
(-> (:data match)
|
(if-let [match (segment/lookup pl slashed-path)]
|
||||||
(assoc :path-params (impl/url-decode-coll (:path-params match)))
|
(-> (:data match)
|
||||||
(assoc :path path))))
|
(assoc :path-params (impl/url-decode-coll (:path-params match)))
|
||||||
|
(assoc :path slashed-path)))))
|
||||||
(match-by-name [_ name]
|
(match-by-name [_ name]
|
||||||
(if-let [match (impl/fast-get lookup name)]
|
(if-let [match (impl/fast-get lookup name)]
|
||||||
(match nil)))
|
(match nil)))
|
||||||
|
|
@ -336,7 +342,7 @@
|
||||||
(route-names [_]
|
(route-names [_]
|
||||||
names)
|
names)
|
||||||
(match-by-path [_ path]
|
(match-by-path [_ path]
|
||||||
(if (#?(:clj .equals :cljs =) p path)
|
(if (#?(:clj .equals :cljs =) p (ensure-slash path))
|
||||||
match))
|
match))
|
||||||
(match-by-name [_ name]
|
(match-by-name [_ name]
|
||||||
(if (= n name)
|
(if (= n name)
|
||||||
|
|
@ -372,8 +378,9 @@
|
||||||
(route-names [_]
|
(route-names [_]
|
||||||
names)
|
names)
|
||||||
(match-by-path [_ path]
|
(match-by-path [_ path]
|
||||||
(or (match-by-path static-router path)
|
(let [slashed-path (ensure-slash path)]
|
||||||
(match-by-path wildcard-router path)))
|
(or (match-by-path static-router path)
|
||||||
|
(match-by-path wildcard-router path))))
|
||||||
(match-by-name [_ name]
|
(match-by-name [_ name]
|
||||||
(or (match-by-name static-router name)
|
(or (match-by-name static-router name)
|
||||||
(match-by-name wildcard-router name)))
|
(match-by-name wildcard-router name)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue