mirror of
https://github.com/metosin/reitit.git
synced 2025-12-23 18:41:11 +00:00
Fast path matching with .equals
This commit is contained in:
parent
40c35a0dfd
commit
da9c94e520
1 changed files with 18 additions and 16 deletions
|
|
@ -104,6 +104,7 @@
|
||||||
(defrecord Route [path matcher parts params meta result])
|
(defrecord Route [path matcher parts params meta result])
|
||||||
|
|
||||||
(defn create [[path meta result]]
|
(defn create [[path meta result]]
|
||||||
|
(let [path #?(:clj (.intern ^String path) :cljs path)]
|
||||||
(if (contains-wilds? path)
|
(if (contains-wilds? path)
|
||||||
(as-> (parse-path path) $
|
(as-> (parse-path path) $
|
||||||
(assoc $ :path-re (path-regex $))
|
(assoc $ :path-re (path-regex $))
|
||||||
|
|
@ -118,8 +119,9 @@
|
||||||
(map->Route $))
|
(map->Route $))
|
||||||
(map->Route {:path path
|
(map->Route {:path path
|
||||||
:meta meta
|
:meta meta
|
||||||
:matcher #(if (= path %) {})
|
:matcher #?(:clj #(if (.equals path %) {})
|
||||||
:result result})))
|
:cljs #(if (= path %)))
|
||||||
|
:result result}))))
|
||||||
|
|
||||||
(defn segments [path]
|
(defn segments [path]
|
||||||
(let [ss (-> (str/split path #"/") rest vec)]
|
(let [ss (-> (str/split path #"/") rest vec)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue