mirror of
https://github.com/metosin/reitit.git
synced 2026-02-25 18:42:24 +00:00
Fix cljs
This commit is contained in:
parent
16499cceb1
commit
3168747540
2 changed files with 10 additions and 3 deletions
|
|
@ -20,9 +20,15 @@
|
||||||
coll
|
coll
|
||||||
coll))
|
coll))
|
||||||
|
|
||||||
(defn segments [path]
|
(defn segments
|
||||||
|
"Splits the path into sequence of segments, using `/` char. Assumes that the
|
||||||
|
path starts with `/`, stripping the first empty segment. e.g.
|
||||||
|
|
||||||
|
(segments \"/a/b/c\") ; => (\"a\" \"b\" \"c\")
|
||||||
|
(segments \"/a/) ; => (\"a\" \"\")"
|
||||||
|
[path]
|
||||||
#?(:clj (SegmentTrie/split ^String path)
|
#?(:clj (SegmentTrie/split ^String path)
|
||||||
:cljs (.split path #"/" 666)))
|
:cljs (rest (.split path #"/" 666))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; https://github.com/pedestal/pedestal/blob/master/route/src/io/pedestal/http/route/prefix_tree.clj
|
;; https://github.com/pedestal/pedestal/blob/master/route/src/io/pedestal/http/route/prefix_tree.clj
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@
|
||||||
:clj (.matcher ^SegmentTrie (or segment (SegmentTrie.)))))
|
:clj (.matcher ^SegmentTrie (or segment (SegmentTrie.)))))
|
||||||
|
|
||||||
(defn lookup [segment path]
|
(defn lookup [segment path]
|
||||||
#?(:cljs (-lookup segment (impl/segments path) {})
|
#?(:cljs (if-let [match (-lookup segment (impl/segments path) {})]
|
||||||
|
(assoc match :path-params (impl/url-decode-coll (:path-params match))))
|
||||||
:clj (if-let [match ^SegmentTrie$Match (SegmentTrie/lookup segment path)]
|
:clj (if-let [match ^SegmentTrie$Match (SegmentTrie/lookup segment path)]
|
||||||
(->Match (.data match) (clojure.lang.PersistentHashMap/create (.params match))))))
|
(->Match (.data match) (clojure.lang.PersistentHashMap/create (.params match))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue