File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,13 @@ QueryString.prototype.stringify = function (params, options) {
2222 // Iterate through the parameters object that was passed to the method
2323 for ( let key in params ) {
2424 if ( params . hasOwnProperty ( key ) ) {
25- // Add the URI encoded key and value to the array separated by an equals
26- queryStringArray . push ( encodeURIComponent ( key ) + '=' + encodeURIComponent ( params [ key ] ) )
25+ // If the element is an array then loop through it
26+ if ( Array . isArray ( params [ key ] ) === true ) {
27+ queryStringArray . push ( encodeURIComponent ( key ) + '=' + encodeURIComponent ( params [ key ] . join ( ',' ) ) ) ;
28+ } else {
29+ // Add the URI encoded key and value to the array separated by an equals
30+ queryStringArray . push ( encodeURIComponent ( key ) + '=' + encodeURIComponent ( params [ key ] ) ) ;
31+ }
2732 }
2833 }
2934
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe('query-stringifier', function () {
2626 } ;
2727 var queryString = qs . stringify ( test3 ) ;
2828
29- expect ( queryString ) . to . equal ( 'column=a,b,c&anotherCol=2' ) ;
29+ expect ( queryString ) . to . equal ( 'column=' + encodeURIComponent ( ' a,b,c' ) + ' &anotherCol=2') ;
3030 } ) ;
3131 } ) ;
3232
You can’t perform that action at this time.
0 commit comments