supersamples icon indicating copy to clipboard operation
supersamples copied to clipboard

Url Decoding

Open GranitB opened this issue 9 years ago • 3 comments

Hi, can I use decoded url's when I generate the doc , because I have url's with parameters and I wont my client to ask me what this %20%

Thank you for your support

GranitB avatar Dec 15 '15 08:12 GranitB

Hi, where do you want the decoded URL to appear?

The problem with decoding is you can end up with invalid URLs, e.g. if the route is /things/:name and the name is foo/bar, then the URL should be /things/foo%2fbar. Showing /things/foo/bar would just be wrong. A space (%20) looks less dangerous, but RFC 1738 says it should always be encoded to avoid confusion, e.g. you might not notice that /things/foo bar actually had two spaces, or a program might decide to merge the spaces.

IMHO a client who consumes APIs should know what %20 means.

rprieto avatar Dec 15 '15 09:12 rprieto

thnx for the answer yes for space is a bad think but , now one uses space in url ( or at list at my project ) but for :

lowest-rates?checkInDate=2015-12-07T09%3A29%3A18.130Z&checkOutDate=2015-12-08T09%3A29%3A18.131Z&codes=HT2%2C1121

these is a problem

GranitB avatar Dec 15 '15 12:12 GranitB

I see what you mean, it's not as easy to read as checkInDate=2015-12-07T09:29:18.130Z. The : character is actually valid in URL paths and queries, I'm not sure why is gets encoded in Supersamples.

encodeURI('http://api.com/path?foo=ba r&message=hello:world')
// "http://api.com/path?foo=ba%20r&message=hello:world"

I'll have a look to see where actually the URL gets encoded.

rprieto avatar Dec 15 '15 12:12 rprieto