(form-decode encoded & [encoding])
Decode the supplied www-form-urlencoded string using the specified encoding,
or UTF-8 by default. If the encoded value is a string, a string is returned.
If the encoded value is a map of parameters, a map is returned.
Source
(defn form-decode
"Decode the supplied www-form-urlencoded string using the specified encoding,
or UTF-8 by default. If the encoded value is a string, a string is returned.
If the encoded value is a map of parameters, a map is returned."
[^String encoded & [encoding]]
(if-not (.contains encoded "=")
(form-decode-str encoded encoding)
(reduce
(fn [m param]
(if-let [[k v] (str/split param #"=" 2)]
(assoc-conj m (form-decode-str k encoding) (form-decode-str v encoding))
m))
{}
(str/split encoded #"&"))))