Skip to content

Commit 96421f9

Browse files
committed
add test for query-param encoding with crazy URL, whitespace and
changelog updates
1 parent a9ffc10 commit 96421f9

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

changelog.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@
269269
- clarify :throw-exceptions in documentation
270270
- define default-middleware for use in wrap-request, remove bad
271271
all-middleware method
272+
- merged https://github.com/dakrone/clj-http/pull/130 to encode
273+
query-params
272274
** 2013-04-04
273275
- merged https://github.com/dakrone/clj-http/pull/124 to handle
274276
URL-encoding invalid characters in the URI

test/clj_http/test/client.clj

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,17 +518,21 @@
518518
(deftest test-url-encode-path
519519
(is (= (client/url-encode-illegal-characters "?foo bar+baz[]75")
520520
"?foo%20bar+baz%5B%5D75"))
521-
(is (= (str "/:@-._~!$&'()*+,="
522-
";"
523-
":@-._~!$&'()*+,"
524-
"="
525-
":@-._~!$&'()*+,==")
521+
(is (= {:uri (str "/:@-._~!$&'()*+,="
522+
";"
523+
":@-._~!$&'()*+,"
524+
"="
525+
":@-._~!$&'()*+,==")
526+
:query-string (str "/?:@-._~!$'()*+,;"
527+
"="
528+
"/?:@-._~!$'()*+,;==")}
526529
;; This URL sucks, yes, it's actually a valid URL
527-
(:uri (client/parse-url
528-
(str "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+"
529-
",=:@-._~!$&'()*+,==?/?:@-._~!$'()*+,;=/?:@-._~!$'("
530-
")*+,;==#/?:@-._~!$&'()*+,;=")))))
530+
(select-keys (client/parse-url
531+
(str "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+"
532+
",=:@-._~!$&'()*+,==?/?:@-._~!$'()*+,;=/?:@-._~!$'("
533+
")*+,;==#/?:@-._~!$&'()*+,;="))
534+
[:uri :query-string])))
531535
(let [all-chars (apply str (map char (range 256)))
532-
all-legal (client/url-encode-illegal-characters all-chars)]
536+
all-legal (client/url-encode-illegal-characters all-chars)]
533537
(is (= all-legal
534538
(client/url-encode-illegal-characters all-legal)))))

0 commit comments

Comments
 (0)