mirror of
https://github.com/metosin/reitit.git
synced 2025-12-25 03:08:25 +00:00
Merge pull request #566 from metosin/toni/update-empty-seq-handling-in-query-string
Handle empty seq as empty string in `query-string`
This commit is contained in:
commit
e84495585c
2 changed files with 7 additions and 1 deletions
|
|
@ -249,6 +249,10 @@
|
|||
(->> params
|
||||
(map (fn [[k v]]
|
||||
(if (or (sequential? v) (set? v))
|
||||
(str/join "&" (map query-parameter (repeat k) v))
|
||||
(if (seq v)
|
||||
(str/join "&" (map query-parameter (repeat k) v))
|
||||
;; Empty seq results in single & character in the query string.
|
||||
;; Handle as empty string to behave similarly as when the value is nil.
|
||||
(query-parameter k ""))
|
||||
(query-parameter k v))))
|
||||
(str/join "&")))
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
{"a" "b"} "a=b"
|
||||
{:a 1} "a=1"
|
||||
{:a nil} "a="
|
||||
{:a []} "a="
|
||||
{:a '()} "a="
|
||||
{:a :b :c "d"} "a=b&c=d"
|
||||
{:a "b c"} "a=b+c"
|
||||
{:a ["b" "c"]} "a=b&a=c"
|
||||
|
|
|
|||
Loading…
Reference in a new issue