File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 44 (:import java.io.File
55 java.util.Map
66 [java.net URLEncoder URLDecoder]
7- org.apache.commons.codec.binary.Base64))
7+ org.apache.commons.codec.binary.Base64
8+ org.apache.commons.codec.net.URLCodec))
89
910(defn assoc-conj
1011 " Associate a key with a value in a map. If the key already exists in the map,
1112 a vector of values is associated with the key."
1213 [map key val]
1314 (assoc map key
14- (if-let [cur (get map key)]
15- (if (vector? cur)
16- (conj cur val)
17- [cur val])
18- val)))
15+ (if-let [cur (get map key)]
16+ (if (vector? cur)
17+ (conj cur val)
18+ [cur val])
19+ val)))
1920
2021(defn- double-escape [^String x]
2122 (.replace (.replace x " \\ " " \\\\ " ) " $" " \\ $" ))
5859 encoding or UTF-8 by default."
5960 [unencoded & [encoding]]
6061 (str/replace
61- unencoded
62- #"[^A-Za-z0-9_~.+-]+"
63- #(double-escape (percent-encode % encoding))))
62+ unencoded
63+ #"[^A-Za-z0-9_~.+-]+"
64+ #(double-escape (percent-encode % encoding))))
6465
6566(defn ^String url-decode
6667 " Returns the url-decoded version of the given string, using either a specified
112113 or UTF-8 by default."
113114 [^String encoded & [encoding]]
114115 (try
115- (URLDecoder/decode encoded (or encoding " UTF-8" ))
116+ (let [codec (URLCodec. (or encoding " UTF-8" ))]
117+ (.decode codec encoded))
116118 (catch Exception _ nil )))
117119
118120(defn form-decode
You can’t perform that action at this time.
0 commit comments