Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the Yesod ecosystem, what is the best way to urlencode some Text?

I'd like to url-encode some Text (e.g., replace each space with a %20, etc.). I found "HTTP" Network.HTTP.Base.urlEncode and could use that, but I'm wondering if there's something else that's normally used in the Yesod ecosystem.

like image 255
Tad Avatar asked Dec 19 '13 06:12

Tad


1 Answers

Unfortunately, due to the complexity of URL escaping, the real answer is "it depends." There are slightly different rules for the percent encoding of path segments and query strings, for example.

I don't know exactly what you're trying to encode, but I'd recommend sticking to the http-types package. One place to start would be urlEncode, though there are many other functions in that packages (such as encodePathSegments mentioned by @jamshidh) which are worth looking at.

like image 112
Michael Snoyman Avatar answered Nov 15 '22 06:11

Michael Snoyman