Skip to content

Commit

Permalink
Fixes #8 : special characters in username
Browse files Browse the repository at this point in the history
  • Loading branch information
gclement authored and gclement committed Jul 3, 2017
1 parent 43f8ce6 commit 1ae6fec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/overwatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ let OverwatchProvider = function () {
break;
}

return url + `${platform}${region}/${tag}`;
return url + `${platform}${region}/${encodeURIComponent(tag)}`;
};

let getSearchUrl = (nickname) => {
return searchUrl + nickname;
return searchUrl + encodeURIComponent(nickname);
};

let parseSeason = (url) => {
Expand Down Expand Up @@ -203,13 +203,10 @@ let OverwatchProvider = function () {
switch (err.response.statusCode) {
case 404:
throw new Error('PROFILE_NOT_FOUND');
break;
case 500:
throw new Error('TECHNICAL_EXCEPTION_HTML_STRUCTURE_MAY_HAVE_CHANGED')
break;
default:
throw new Error('TECHNICAL_EXCEPTION_NOT_IDENTIFIED')
break;
}
}

Expand All @@ -218,6 +215,7 @@ let OverwatchProvider = function () {
}

self.getAll = (platform, region, tag, overallOnly) => {
//tag = unescape(tag);
var baseurl = getUrl(platform, region, tag);
return rp(baseurl).then((context) => {

Expand Down
6 changes: 5 additions & 1 deletion specs/mocktest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

var ow = require('../index.js');

ow.search('Zeya-2303')
ow.search('SĔNPAI-1698')
.then((data) => console.dir(data, {depth : 3, colors : true}) );

ow.getAll('pc', 'eu', 'Zeya-2303')
.then((data) => console.dir(data, {depth : 2, colors : true}) );

//// Special characters
ow.getAll('pc', 'us', 'SĔNPAI-1698')
.then((data) => console.dir(data, {depth : 2, colors : true}) );

0 comments on commit 1ae6fec

Please sign in to comment.