File tree 1 file changed +12
-10
lines changed
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 4
4
(:import java.io.File
5
5
java.util.Map
6
6
[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))
8
9
9
10
(defn assoc-conj
10
11
" Associate a key with a value in a map. If the key already exists in the map,
11
12
a vector of values is associated with the key."
12
13
[map key val]
13
14
(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)))
19
20
20
21
(defn- double-escape [^String x]
21
22
(.replace (.replace x " \\ " " \\\\ " ) " $" " \\ $" ))
58
59
encoding or UTF-8 by default."
59
60
[unencoded & [encoding]]
60
61
(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))))
64
65
65
66
(defn ^String url-decode
66
67
" Returns the url-decoded version of the given string, using either a specified
112
113
or UTF-8 by default."
113
114
[^String encoded & [encoding]]
114
115
(try
115
- (URLDecoder/decode encoded (or encoding " UTF-8" ))
116
+ (let [codec (URLCodec. (or encoding " UTF-8" ))]
117
+ (.decode codec encoded))
116
118
(catch Exception _ nil )))
117
119
118
120
(defn form-decode
You can’t perform that action at this time.
0 commit comments