From 7fb6a99183ea2f5f6bedd7d08b1cdb0e1c41b0f5 Mon Sep 17 00:00:00 2001 From: Aaron Blenkush <aaron.blenkush@projecta.com> Date: Fri, 11 Aug 2017 10:28:33 -0700 Subject: [PATCH 1/3] Allow repeated keys in query params https://github.com/cemerick/url/issues/13 --- src/cemerick/url.cljx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cemerick/url.cljx b/src/cemerick/url.cljx index 75ff53d..356f03d 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,14 @@ (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)) + (update params k)))) + {})))) (defn- port-str [protocol port] From 5799c7c034b961902fcd9573d171d365120d27dd Mon Sep 17 00:00:00 2001 From: Aaron Blenkush <aaron.blenkush@projecta.com> Date: Fri, 11 Aug 2017 10:54:28 -0700 Subject: [PATCH 2/3] replace update with assoc --- src/cemerick/url.cljx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cemerick/url.cljx b/src/cemerick/url.cljx index 356f03d..03b2ccd 100644 --- a/src/cemerick/url.cljx +++ b/src/cemerick/url.cljx @@ -54,11 +54,12 @@ seq (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)) - (update params k)))) + (->> ((fn [vs] + (if vs + (conj (if (vector? vs) vs [vs]) v) + v)) + (get params k)) + (assoc params k)))) {})))) (defn- port-str From 953537d5cd5d622fd9045337b89256d131cd1b0f Mon Sep 17 00:00:00 2001 From: Aaron Blenkush <aaron.blenkush@projecta.com> Date: Thu, 27 Feb 2020 08:28:23 -0800 Subject: [PATCH 3/3] Fork 0.1.3 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"