refactor: remove repetitions

This commit is contained in:
Luca Cervello 2026-02-06 12:01:44 +01:00
parent 97bfafa907
commit 4c8a69c616
2 changed files with 14 additions and 19 deletions

View file

@ -122,9 +122,8 @@
(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)))
(match-by-name [_ name path-params] (match-by-name [r name path-params]
(if-let [match (impl/fast-get lookup name)] (match-by-name r name path-params nil))
(match (impl/path-params path-params))))
(match-by-name [_ name path-params opts] (match-by-name [_ name path-params opts]
(if-let [match (impl/fast-get lookup name)] (if-let [match (impl/fast-get lookup name)]
(match (impl/path-params path-params opts)))))))) (match (impl/path-params path-params opts))))))))
@ -164,9 +163,8 @@
(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)))
(match-by-name [_ name path-params] (match-by-name [r name path-params]
(if-let [match (impl/fast-get lookup name)] (match-by-name r name path-params nil))
(match (impl/path-params path-params))))
(match-by-name [_ name path-params opts] (match-by-name [_ name path-params opts]
(if-let [match (impl/fast-get lookup name)] (if-let [match (impl/fast-get lookup name)]
(match (impl/path-params path-params opts)))))))) (match (impl/path-params path-params opts))))))))
@ -214,9 +212,8 @@
(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)))
(match-by-name [_ name path-params] (match-by-name [r name path-params]
(if-let [match (impl/fast-get lookup name)] (match-by-name r name path-params nil))
(match (impl/path-params path-params))))
(match-by-name [_ name path-params opts] (match-by-name [_ name path-params opts]
(if-let [match (impl/fast-get lookup name)] (if-let [match (impl/fast-get lookup name)]
(match (impl/path-params path-params opts)))))))) (match (impl/path-params path-params opts))))))))
@ -247,8 +244,8 @@
(if (#?(:clj .equals :cljs =) p path) match)) (if (#?(:clj .equals :cljs =) p path) match))
(match-by-name [_ name] (match-by-name [_ name]
(if (= n name) match)) (if (= n name) match))
(match-by-name [_ name path-params] (match-by-name [r name path-params]
(if (= n name) (impl/fast-assoc match :path-params (impl/path-params path-params)))) (match-by-name r name path-params nil))
(match-by-name [_ name path-params opts] (match-by-name [_ name path-params opts]
(if (= n name) (impl/fast-assoc match :path-params (impl/path-params path-params opts)))))))) (if (= n name) (impl/fast-assoc match :path-params (impl/path-params path-params opts))))))))
@ -279,9 +276,8 @@
(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)))
(match-by-name [_ name path-params] (match-by-name [r name path-params]
(or (match-by-name static-router name path-params) (match-by-name r name path-params nil))
(match-by-name wildcard-router name path-params)))
(match-by-name [_ name path-params opts] (match-by-name [_ name path-params opts]
(or (match-by-name static-router name path-params opts) (or (match-by-name static-router name path-params opts)
(match-by-name wildcard-router name path-params opts))))))) (match-by-name wildcard-router name path-params opts)))))))
@ -313,9 +309,8 @@
(match-by-name [_ name] (match-by-name [_ name]
(or (match-by-name mixed-router name) (or (match-by-name mixed-router name)
(match-by-name linear-router name))) (match-by-name linear-router name)))
(match-by-name [_ name path-params] (match-by-name [r name path-params]
(or (match-by-name mixed-router name path-params) (match-by-name r name path-params nil))
(match-by-name linear-router name path-params)))
(match-by-name [_ name path-params opts] (match-by-name [_ name path-params opts]
(or (match-by-name mixed-router name path-params opts) (or (match-by-name mixed-router name path-params opts)
(match-by-name linear-router name path-params opts))))))) (match-by-name linear-router name path-params opts)))))))

View file

@ -297,10 +297,10 @@
(defn path-params (defn path-params
"Convert parameters' values into URL-encoded strings, suitable for URL paths" "Convert parameters' values into URL-encoded strings, suitable for URL paths"
([params] (maybe-map-values #(url-encode (into-string %)) params)) ([params] (path-params params nil))
([params {:keys [url-encode?] :or {url-encode? true}}] ([params {:keys [url-encode?] :or {url-encode? true}}]
(if url-encode? (if url-encode?
(path-params params) (maybe-map-values #(url-encode (into-string %)) params)
(maybe-map-values #(into-string %) params)))) (maybe-map-values #(into-string %) params))))
(defn- query-parameter [k v] (defn- query-parameter [k v]