ring-clojure / ring-codec

Utility library for encoding and decoding data
MIT License
63 stars 30 forks source link

Treat sets in form-encode like seq or sequential #9

Closed nkabrich closed 6 years ago

nkabrich commented 9 years ago

This extends encoding so that sets are treated in the same way as e.g. vectors. Although there is no strict standard for encoding array-like objects as query strings I think it makes sense that encoding {:a #{1 2}} should result in the same thing as {:a [1 2]} instead of resulting in the encoding of the string "#{1 2}". This way it will return "a=1&a=2" instead of "a=%23%7B1+2%7D".

Especially if used for client side consumption or non-clojure based libraries, doesn't it make sense to have a set be represented as some array-like thing? Or maybe there is a good reason not to do this I'm not aware of or this shouldn't be included because a standard doesn't exist. Thanks.

weavejester commented 6 years ago

I've only just noticed this PR while doing some maintainance work, so apologies for not replying initially. If sets are supported, we need tests, and we need to ensure the output is predictable (i.e. sorted).

weavejester commented 6 years ago

Fixed by 1c71e2a