Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Allow repeated keys in query params #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.cemerick/url "0.1.2-SNAPSHOT"
(defproject aaronblenkush/url "0.1.3"
:description "Makes working with URLs in Clojure a little more pleasant."
:url "http://github.com/cemerick/url"
:license {:name "Eclipse Public License"
Expand Down
22 changes: 15 additions & 7 deletions src/cemerick/url.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
[m]
(some->> (seq m)
sort ; sorting makes testing a lot easier :-)
(map (fn [[k v]]
[(url-encode (name k))
"="
(url-encode (str v))]))
(mapcat (fn [[k vs]]
(->> (if (vector? vs) vs [vs])
(map #(vector
(url-encode (name k))
"="
(url-encode (str %)))))))
(interpose "&")
flatten
(apply str)))
Expand All @@ -50,9 +52,15 @@
(when (not (string/blank? qstr))
(some->> (string/split qstr #"&")
seq
(mapcat split-param)
(map url-decode)
(apply hash-map))))
(reduce (fn [params param]
(let [[k v] (map url-decode (split-param param))]
(->> ((fn [vs]
(if vs
(conj (if (vector? vs) vs [vs]) v)
v))
(get params k))
(assoc params k))))
{}))))

(defn- port-str
[protocol port]
Expand Down