Skip to content

Commit

Permalink
#298 - Correctly Url Encode arrays in iron-request when content-type …
Browse files Browse the repository at this point in the history
…is x-www-form-urlencoded
  • Loading branch information
dejan9393 authored and Dejan committed Oct 20, 2017
1 parent 536c76a commit 77dac94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iron-ajax",
"version": "2.0.5",
"version": "2.0.6",
"description": "Makes it easy to make ajax calls and parse the response",
"private": true,
"authors": [
Expand Down
15 changes: 10 additions & 5 deletions iron-request.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,16 @@
}
var pieces = [];
Object.keys(object).forEach(function(key) {
// TODO(rictic): handle array values here, in a consistent way with
// iron-ajax params.
pieces.push(
this._wwwFormUrlEncodePiece(key) + '=' +
this._wwwFormUrlEncodePiece(object[key]));
if( !Array.isArray(object[key])) {
// Cast to array.
object[key] = [object[key]];
}

for( var i = 0; i < object[key].length; i++ ) {
pieces.push(
this._wwwFormUrlEncodePiece(key) + '=' +
this._wwwFormUrlEncodePiece(object[key][i]));
}
}, this);
return pieces.join('&');
},
Expand Down

0 comments on commit 77dac94

Please sign in to comment.