Skip to content

Commit 2946e9c

Browse files
author
Matt Revelle
committed
Fixed optional params out of order bug. Patch contributed from Zehua Liu.
1 parent 5a3efa6 commit 2946e9c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/twitter.clj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ take any required and optional arguments and call the associated Twitter method.
5151
rest-map# (apply hash-map rest#)
5252
provided-optional-params# (set/intersection (set ~optional-params)
5353
(set (keys rest-map#)))
54-
query-param-names# (sort (map (fn [x#] (keyword (string/replace (name x#) #"-" "_")))
55-
(concat ~required-params provided-optional-params#)))
56-
query-params# (apply hash-map (interleave query-param-names#
57-
(vec (concat ~required-fn-params
58-
(vals (sort (select-keys rest-map#
59-
provided-optional-params#)))))))
54+
required-query-param-names# (map (fn [x#]
55+
(keyword (string/replace (name x#) #"-" "_" )))
56+
~required-params)
57+
optional-query-param-names-mapping# (map (fn [x#]
58+
[x# (keyword (string/replace (name x#) #"-" "_"))])
59+
provided-optional-params#)
60+
query-params# (merge (apply hash-map
61+
(vec (interleave required-query-param-names# ~required-fn-params)))
62+
(apply merge
63+
(map (fn [x#] {(second x#) ((first x#) rest-map#)}) optional-query-param-names-mapping#)))
6064
need-to-url-encode# (if (= :get ~req-method)
6165
(into {} (map (fn [[k# v#]] [k# (oauth.signature/url-encode v#)]) query-params#))
6266
query-params#)

0 commit comments

Comments
 (0)