pulviscriptor / agario-client

Node.js agar.io client implementation
MIT License
80 stars 43 forks source link

decodeURI #158

Closed Nick8fr32 closed 8 years ago

Nick8fr32 commented 8 years ago

i get this error when i try to get the tokens??

if(xs && xs.indexOf('%')) xs = decodeURIComponent(xs);
                               ^

URIError: URI malformed

pulviscriptor commented 8 years ago

I made it use decode because lots of users don't decode their cookies before use and reporting problems because of this. https://github.com/pulviscriptor/agario-client/blob/master/account.js#L50 If you really need % symbol (which i think you don't and you have some problem somewhere setting xs to some wrong value) you can encode your cookies https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

DRSDavidSoft commented 8 years ago

Using Regular Expression (in my next PR), we can try to find out if using decodeURIComponent is really necessary.

var find_hex = /\%[0-9A-F]{2}/i;
...
if(xs && xs.match(find_hex)) xs = decodeURIComponent(xs);

This way, chances are more unlikely to get URI malformed error. Close this issue if this helps

pulviscriptor commented 8 years ago

Updated NPM package to 1.3.7 with DRSDavidSoft's fix.