Skip to content

Commit c9fce15

Browse files
committed
Fix check for options and add test
Relates to dakrone@47a7762#r27529460
1 parent 564cfa0 commit c9fce15

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/clj_http/client.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,8 @@
882882

883883
(defn- nested-keys-to-flatten
884884
[{:keys [flatten-nested-keys] :as req}]
885-
(when (and (not (nil? (opt req :ignore-nested-query-string)))
886-
(not (nil? (opt req :flatten-nested-form-params)))
885+
(when (and (or (not (nil? (opt req :ignore-nested-query-string)))
886+
(not (nil? (opt req :flatten-nested-form-params))))
887887
flatten-nested-keys)
888888
(throw (IllegalArgumentException.
889889
(str "only :flatten-nested-keys or :ignore-nested-query-string/"

test/clj_http/test/client_test.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,16 @@
13121312
{:flatten-nested-form-params true
13131313
:ignore-nested-query-string true
13141314
:flatten-nested-keys [:thing :bar]})
1315+
(is false "should have thrown exception")
1316+
(catch IllegalArgumentException e
1317+
(is (= (.getMessage e)
1318+
(str "only :flatten-nested-keys or :ignore-nested-query-string/"
1319+
":flatten-nested-keys may be specified, not both")))))
1320+
(try
1321+
((client/wrap-flatten-nested-params identity)
1322+
{:ignore-nested-query-string true
1323+
:flatten-nested-keys [:thing :bar]})
1324+
(is false "should have thrown exception")
13151325
(catch IllegalArgumentException e
13161326
(is (= (.getMessage e)
13171327
(str "only :flatten-nested-keys or :ignore-nested-query-string/"

0 commit comments

Comments
 (0)