purescript-hyper / hyper

Type-safe, statically checked composition of HTTP servers
https://hyper.wickstrom.tech
Mozilla Public License 2.0
282 stars 29 forks source link

Should we treat `+` as `%20` in uri query part? #51

Open paluh opened 6 years ago

paluh commented 6 years ago

I've described details here: https://github.com/slamdata/purescript-uri/issues/38

owickstrom commented 6 years ago

Good question. In my opinion, the purescript-uri package would be a strange place to have this "fix", at least more so than in Hyper. That said, I'm leaning towards not supporting + as encoded space in Hyper either, at least not by default. Not sure if it makes sense to have it configurable either... What do you think?

paluh commented 6 years ago

@owickstrom I'm not sure how to politely continue this discussion as I've opened two different tickets on the same topic :-) I can copy all related comments from purescript-uri thread here too for completeness if you want.

Anyway, I've tested some browsers behavior and checked how other libraries are treating + in queries. You can find results of "my research" in the latest comment here: https://github.com/slamdata/purescript-uri/issues/38#issuecomment-345710976

paluh commented 6 years ago

I think I'm going to provide

type Options = { replacePlus :: Boolean }                                                                                                                              

defaultOptions :: Options                                                                                                                                              
defaultOptions = { replacePlus: true }

and change

parseUrlencoded :: Options -> String -> Either String (Array (Tuple String (Maybe String))

Does it sound good to you?