Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Url Decoding #31

Open
GranitB opened this issue Dec 15, 2015 · 3 comments
Open

Url Decoding #31

GranitB opened this issue Dec 15, 2015 · 3 comments

Comments

@GranitB
Copy link

GranitB commented Dec 15, 2015

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

@rprieto
Copy link
Owner

rprieto commented Dec 15, 2015

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.

@GranitB
Copy link
Author

GranitB commented Dec 15, 2015

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

@rprieto
Copy link
Owner

rprieto commented Dec 15, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants