Skip to content

Commit 937dd4f

Browse files
authored
Merge pull request #20 from pieter-van-prooijen/issue-ring-312-cant-use-query-parameters-without-a-value
Change missing parameter values to empty strings
2 parents 6fea0ef + 61488f8 commit 937dd4f

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/ring/util/codec.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
(reduce
143143
(fn [m param]
144144
(if-let [[k v] (str/split param #"=" 2)]
145-
(assoc-conj m (form-decode-str k encoding) (form-decode-str v encoding))
145+
(assoc-conj m (form-decode-str k encoding) (form-decode-str (or v "") encoding))
146146
m))
147147
{}
148148
(str/split encoded #"&")))))

test/ring/util/test/codec.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"a=b&c=d" {"a" "b" "c" "d"}
6363
"foo+bar" "foo bar"
6464
"a=b+c" {"a" "b c"}
65-
"a=b%2Fc" {"a" "b/c"})
65+
"a=b%2Fc" {"a" "b/c"}
66+
"a=b&c" {"a" "b" "c" ""}
67+
"a=&b=c" {"a" "" "b" "c"}
68+
"a&b=c" {"a" "" "b" "c"})
6669
(is (= (form-decode "a=foo%FE%FF%00%2Fbar" "UTF-16")
6770
{"a" "foo/bar"})))

0 commit comments

Comments
 (0)