diff --git a/project.clj b/project.clj index 970736b..c33acb6 100644 --- a/project.clj +++ b/project.clj @@ -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" diff --git a/src/cemerick/url.cljx b/src/cemerick/url.cljx index 75ff53d..03b2ccd 100644 --- a/src/cemerick/url.cljx +++ b/src/cemerick/url.cljx @@ -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))) @@ -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]