diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd6e8ef..5a74c12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
+### 2.1.2
+- Force escaping of all url params (#34)
+
### 2.1.1
-- Fix bug preventing match_id and participant_id passed as underscore properties for URL generation #32
+- Fix bug preventing match_id and participant_id passed as underscore properties for URL generation (#32)
### 2.1.0
- Fix null values being returned as empty objects (#24)
diff --git a/docs/Client.html b/docs/Client.html
index 4f60584..21a07ae 100644
--- a/docs/Client.html
+++ b/docs/Client.html
@@ -383,7 +383,7 @@
Properties
diff --git a/docs/Matches.html b/docs/Matches.html
index 4bdb3fe..3e76dad 100644
--- a/docs/Matches.html
+++ b/docs/Matches.html
@@ -945,7 +945,7 @@ Properties
diff --git a/docs/Participants.html b/docs/Participants.html
index 68883fe..a77482e 100644
--- a/docs/Participants.html
+++ b/docs/Participants.html
@@ -1645,7 +1645,7 @@ Properties
diff --git a/docs/Tournaments.html b/docs/Tournaments.html
index 5ce12c6..1eaecb0 100644
--- a/docs/Tournaments.html
+++ b/docs/Tournaments.html
@@ -2356,7 +2356,7 @@ Properties
diff --git a/docs/api_client.js.html b/docs/api_client.js.html
index 1338862..85e59de 100644
--- a/docs/api_client.js.html
+++ b/docs/api_client.js.html
@@ -131,11 +131,10 @@ api/client.js
const serialized = util.serializeToQSParams(obj);
path = versionPaths[this.options.get('version')] + (path ? path : '') + '.' + this.options.get('format') + '?' + serialized;
-
// create options for the https call
const options = {
hostname: 'api.challonge.com',
- path: path,
+ path: encodeURI(path),
method: method,
headers: {
'Content-Length': 0 // server throws nginx error without a content-length
@@ -180,7 +179,7 @@ api/client.js
diff --git a/docs/api_error-handler.js.html b/docs/api_error-handler.js.html
index c39d6e1..cb5497f 100644
--- a/docs/api_error-handler.js.html
+++ b/docs/api_error-handler.js.html
@@ -120,7 +120,7 @@ api/error-handler.js
diff --git a/docs/api_matches.js.html b/docs/api_matches.js.html
index 1e1f1bf..0501f1d 100644
--- a/docs/api_matches.js.html
+++ b/docs/api_matches.js.html
@@ -160,7 +160,7 @@ api/matches.js
diff --git a/docs/api_participants.js.html b/docs/api_participants.js.html
index 454bf1e..3a50745 100644
--- a/docs/api_participants.js.html
+++ b/docs/api_participants.js.html
@@ -249,7 +249,7 @@ api/participants.js
diff --git a/docs/api_tournaments.js.html b/docs/api_tournaments.js.html
index c527c48..dc2990a 100644
--- a/docs/api_tournaments.js.html
+++ b/docs/api_tournaments.js.html
@@ -361,7 +361,7 @@ api/tournaments.js
diff --git a/docs/challonge.js.html b/docs/challonge.js.html
index e7c8015..b42532b 100644
--- a/docs/challonge.js.html
+++ b/docs/challonge.js.html
@@ -89,7 +89,7 @@ challonge.js
diff --git a/docs/global.html b/docs/global.html
index a419c5a..aa6383e 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -450,7 +450,7 @@ Returns:
diff --git a/docs/index.html b/docs/index.html
index f6f75d7..c04309c 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -103,7 +103,7 @@ Branching
master
is the active development branch
diff --git a/docs/module-ErrorHandler.html b/docs/module-ErrorHandler.html
index b701239..5db1714 100644
--- a/docs/module-ErrorHandler.html
+++ b/docs/module-ErrorHandler.html
@@ -366,7 +366,7 @@ Parameters:
diff --git a/docs/module-Util.html b/docs/module-Util.html
index c1a0489..1797f81 100644
--- a/docs/module-Util.html
+++ b/docs/module-Util.html
@@ -857,7 +857,7 @@ Returns:
diff --git a/docs/param-serializer.js.html b/docs/param-serializer.js.html
index e8d84fb..05ad306 100644
--- a/docs/param-serializer.js.html
+++ b/docs/param-serializer.js.html
@@ -107,7 +107,7 @@ param-serializer.js
diff --git a/docs/util.js.html b/docs/util.js.html
index 717e73f..1ef5882 100644
--- a/docs/util.js.html
+++ b/docs/util.js.html
@@ -121,7 +121,7 @@ util.js
diff --git a/lib/api/client.js b/lib/api/client.js
index 447bd3a..e04c8f2 100644
--- a/lib/api/client.js
+++ b/lib/api/client.js
@@ -92,11 +92,10 @@ Client.prototype.makeRequest = function(obj) {
const serialized = util.serializeToQSParams(obj);
path = versionPaths[this.options.get('version')] + (path ? path : '') + '.' + this.options.get('format') + '?' + serialized;
-
// create options for the https call
const options = {
hostname: 'api.challonge.com',
- path: path,
+ path: encodeURI(path),
method: method,
headers: {
'Content-Length': 0 // server throws nginx error without a content-length
diff --git a/lib/api/client.spec.js b/lib/api/client.spec.js
index 4e20b6b..f89c0b8 100644
--- a/lib/api/client.spec.js
+++ b/lib/api/client.spec.js
@@ -215,7 +215,26 @@ describe('Client Class', () => {
expect(httpsMock.opts).toEqual({
hostname: 'api.challonge.com',
- path: '/v1/tournaments/some/path.json?randomprop=thingie&some_property[another_property]=anotherthing&api_key=mykey&cache_bust=1',
+ path: '/v1/tournaments/some/path.json?randomprop=thingie&some_property%5Banother_property%5D=anotherthing&api_key=mykey&cache_bust=1',
+ method: 'GET',
+ headers: {
+ 'Content-Length': 0
+ }
+ });
+ });
+
+ it('should make a request with escaped data for extended characters', () => {
+ spyOn(Math, 'random').and.returnValue(1);
+ client.options.apiKey = 'mykey';
+ client.makeRequest({
+ path: '/some/path',
+ method: 'GET',
+ randomprop: '扶摇ståleSÓLO独播'
+ });
+
+ expect(httpsMock.opts).toEqual({
+ hostname: 'api.challonge.com',
+ path: '/v1/tournaments/some/path.json?randomprop=%E6%89%B6%E6%91%87st%C3%A5leS%C3%93LO%E7%8B%AC%E6%92%AD&api_key=mykey&cache_bust=1',
method: 'GET',
headers: {
'Content-Length': 0
diff --git a/package.json b/package.json
index f3c1ac6..5e3c1eb 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"description": "Wrapper for the challong api",
"author": "Aaron Tiwell ",
"main": "./lib/challonge.js",
- "version": "2.1.1",
+ "version": "2.1.2",
"contributors": [
{
"name": "Ricardo Reis",
diff --git a/test/full.js b/test/full.js
index c60e688..c444e70 100644
--- a/test/full.js
+++ b/test/full.js
@@ -6,7 +6,7 @@ var client = challonge.createClient({
version: 1,
});
-var tourneyName = 'new_api_test' + Math.floor(Math.random()*10000);
+var tourneyName = 'new_api_test扶摇ståleSÓLO独播' + Math.floor(Math.random()*10000);
client.tournaments.create({
tournament: {
@@ -31,7 +31,7 @@ function update() {
url: tourneyName,
signupCap: 16,
tournamentType: 'double elimination',
- description: 'some new description',
+ description: 'some new description扶摇ståleSÓLO独播',
acceptAttachments: true
},
@@ -39,7 +39,7 @@ function update() {
if (err) { console.log(err); return; }
console.log(data);
- pcreate('player1');
+ pcreate('player1扶摇ståleSÓLO独播');
}
});
}
@@ -53,7 +53,7 @@ function pcreate(name) {
callback: function(err,data){
if (err) { console.log(err); return; }
console.log(data);
- if (name === 'player1') {
+ if (name === 'player1扶摇ståleSÓLO独播') {
pcreate('player2');
} else {
start();