lambdaisland / uri

A pure Clojure/ClojureScript URI library
Mozilla Public License 2.0
243 stars 21 forks source link

Query-string nil values validity? #48

Closed velios closed 9 months ago

velios commented 10 months ago

Hi. First of all thx for great tool. I'm not sure this expected behaviour

(-> (uri/parse "https://example.com")
    (assoc :query (uri/map->query-string {:aaa nil :bbb nil}))
    (str))
=> "https://example.com?"

I expected to get https://example.com?aaa=&bbb= or https://example.com Maybe I'm wrong, I would like to know your opinion. I might do a PR if I know the expected behavior.

velios commented 9 months ago

Probably in this case I’m still wrong and empty strings should be used to pass empty string values. Like this (assoc :query (uri/map->query-string {:aaa "" :bbb ""})). True, this is not obvious, perhaps it is worth adding this to the readme