evancz / url-parser

Parse URLs into nicely structured data
http://package.elm-lang.org/packages/evancz/url-parser/latest/
BSD 3-Clause "New" or "Revised" License
114 stars 29 forks source link

Support query params with no values. #36

Closed amilner42 closed 7 years ago

amilner42 commented 7 years ago

For the use-case where you want a query param but it carries no connected value. You can see here (or jump directly to the RFC here) that this is fully valid.

It just seems silly to do something like Maybe () when you really just want a boolean.

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 7 years ago

Tracking in #41. Can you provide an example of exactly the URL you want to parse and why you want to do that? That would help me understand your goals with this request better.

NeverwinterMoon commented 7 years ago

@evancz I am also in dire need of the same functionality. Our use case is this, we have "f" (as in first time) parameter in URL when a customer opens a page after purchase (the page is sort of a fancy receipt). Based on that, we show some banner. The same link can be opened from, say, email and it doesn't have the "f" parameter, so we don't show that same banner. We could have of course had "f=true", but we knew that parameter without a value is considered valid, and it was much shorter, so for us the presence of "f" means "f=true" and the absence is "f=false".

amilner42 commented 7 years ago

@evancz My apologies, I meant to respond sooner but I've been really busy.

I have a roughly similar situation to @NeverwinterMoon, also wanting parser support for a query param with no connected value (which is valid).