miasmos / op.gg-api

Serves op.gg web pages as json.
MIT License
81 stars 21 forks source link

Special Characters in Summonername result in empty result #3

Closed freakpants closed 9 years ago

freakpants commented 9 years ago

Presumably because special characters are not escaped in the url for the request to op.gg?

Example Summoner: Bêluga (euw)

freakpants commented 9 years ago

this fix seems to now result in spaces being escaped twice :/

miasmos commented 9 years ago

Could you provide an example of this happening?

freakpants commented 9 years ago

im using php to call the endpoint - generating an url that replaces spaces with plus signs. I fixed the issue for summoner names with single spaces (eg. silent Yuma) by replacing the plus sign with a space before it gets encoded. that however breaks players with 2 spaces. (BEV BUS Driver)

freakpants commented 9 years ago

options.url = 'http://'+req.params.region+'.op.gg/summoner/userName='+encodeURIComponent(req.params.summoner.replace("+"," "));

is the fix i currently use - the correct way would probably to decode the summoner

freakpants commented 9 years ago

I think you misunderstood me. I call the endpoint with an url like http://localhost:1337/euw/summoner/BEV+ROBINWASDIA

Node then receives "BEV+ROBINWASDIA" as the summoner name. There are no Spaces to be replaced, just the plus sign which php adds because otherwise i couldnt make a http request because a valid url doesnt have spaces. However - removing spaces on my end before calling the endpoint solves the issue as well. I hope I made myself clearer.

miasmos commented 9 years ago

Should be fixed now