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
Dejan committed Oct 20, 2017
1 parent 536c76a commit b9b63f7
Showing 1 changed file with 10 additions and 5 deletions.
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 b9b63f7

Please sign in to comment.