nick1n / nicholast.fm

Last.fm Stat Utility Web App
https://nicholast.fm
21 stars 1 forks source link

Links for artists and tracks with special characters don't work. #23

Closed nick1n closed 11 years ago

nick1n commented 12 years ago

special characters such as + and /

namklabs commented 12 years ago

Do we need to use htmlescapeentities() or something?

nick1n commented 12 years ago

Looks like I just need to use encodeURI but I thought I was, maybe I'm not using it correctly.

namklabs commented 12 years ago

Do you have a commit # I could look at?

nick1n commented 12 years ago

No, its always has been in there, just open app.js and search for encodeURI

nick1n commented 12 years ago

hmm it seems that encodeURI doesn't encode + and / characters and maybe even a few others might need to use something else or have special cases for those

nick1n commented 12 years ago

Yea, it looks like I'll just have to use encodeURIComponent instead of encodeURI

nick1n commented 12 years ago

Looking into even more, it looks like even encodeURIComponent won't catch everything, source: http://stackoverflow.com/questions/332872/how-to-encode-a-url-in-javascript So, will probably have to create a helper function to do it properly.

nick1n commented 12 years ago

Ok, it looks like last.fm is encoding some special characters, such as +, twice for their urls. So, a + will be encoded as %252B, %25 is the encoded value for %, making it decode(%252B) = %2B and %2B is the encoded value for +. Now just need to figure out which other special characters last.fm does this for :)

nick1n commented 11 years ago

Going to close this for now, hopefully spaces and pluses are the only special cases for last.fm links.