Add more adaptations to make app run in a prefixed path.

This commit is contained in:
Andrey Antukh 2021-04-19 18:35:36 +02:00 committed by Andrés Moya
parent 2828ccda7f
commit 55ea84a056
14 changed files with 115 additions and 98 deletions

View file

@ -0,0 +1,34 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) UXBOX Labs SL
(ns app.common.uri
(:require
[app.common.data :as d]
[lambdaisland.uri :as u]
[lambdaisland.uri.normalize :as un]))
(d/export u/uri)
(d/export u/join)
(d/export un/percent-encode)
(defn query-string->map
[s]
(u/query-string->map s))
(defn default-encode-value
[v]
(if (keyword? v) (name v) v))
(defn map->query-string
([params] (map->query-string params nil))
([params {:keys [value-fn key-fn]
:or {value-fn default-encode-value
key-fn identity}}]
(->> params
(into {} (comp
(remove #(nil? (second %)))
(map (fn [[k v]] [(key-fn k) (value-fn v)]))))
(u/map->query-string))))