sebonlien / bitly-api

Automatically exported from code.google.com/p/bitly-api
0 stars 0 forks source link

Use encodeURI instead #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In http://code.google.com/p/bitly-api/wiki/ApiBestPractices#URL_Encoding , it 
recommends using encodeURIComponent encode longUrl in Javascript. However, the 
API will return INVALID_URI if that's used. Instead, it should say use 
encodeURI instead.

http://betaworks.com/:
  encoded using encodeURIComponent: http%253A%252F%252Fbetaworks.com%252F
  encoded using encodeURI: http%3A%2F%2Fbetaworks.com%2F

Original issue reported on code.google.com by haochi.chen on 30 Sep 2010 at 11:14

GoogleCodeExporter commented 8 years ago
encodeURIComponent() is the correct javascript method to encode a parameter 
used in a query string. Please check your usage

> encodeURIComponent('http://betaworks.com/') == "http%3A%2F%2Fbetaworks.com%2F"
> encodeURI('http://betaworks.com/') == "http://betaworks.com/"

it sounds like you have some post processing you are unaware of that is also 
calling encodeURIComponent for you.

Original comment by jehiah on 20 Oct 2010 at 3:15