Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Allow a mix of keyword and string keys in :query #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cemerick/url.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(defn map->query
[m]
(some->> (seq m)
sort ; sorting makes testing a lot easier :-)
(sort-by (fn [[k v]] (name k))) ; sorting makes testing a lot easier :-)
(map (fn [[k v]]
[(url-encode (name k))
"="
Expand Down
6 changes: 6 additions & 0 deletions test/cemerick/test_url.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
nil nil
"" nil))

(deftest query-mixed-keys
(is (= "https://localhost:80?baz=bam&foo=bar"
(-> (url "https://localhost:80?foo=bar")
(assoc-in [:query :baz] "bam")
str))))

(deftest user-info-edgecases
(are [user-info url-string] (= user-info ((juxt :username :password) (url url-string)))
["a" nil] "http://a@foo"
Expand Down