File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -333,10 +333,21 @@ var Hash = Class.create(Enumerable, (function() {
333
333
function toQueryString ( ) {
334
334
return this . inject ( [ ] , function ( results , pair ) {
335
335
var key = encodeURIComponent ( pair . key ) , values = pair . value ;
336
-
336
+
337
337
if ( values && typeof values == 'object' ) {
338
- if ( Object . isArray ( values ) )
339
- return results . concat ( values . map ( toQueryPair . curry ( key ) ) ) ;
338
+ if ( Object . isArray ( values ) ) {
339
+ // We used to use `Array#map` here to get the query pair for each
340
+ // item in the array, but that caused test regressions once we
341
+ // added the sparse array behavior for array iterator methods.
342
+ // Changed to an ordinary `for` loop so that we can handle
343
+ // `undefined` values ourselves rather than have them skipped.
344
+ var queryValues = [ ] ;
345
+ for ( var i = 0 , len = values . length , value ; i < len ; i ++ ) {
346
+ value = values [ i ] ;
347
+ queryValues . push ( toQueryPair ( key , value ) ) ;
348
+ }
349
+ return results . concat ( queryValues ) ;
350
+ }
340
351
} else results . push ( toQueryPair ( key , values ) ) ;
341
352
return results ;
342
353
} ) . join ( '&' ) ;
You can’t perform that action at this time.
0 commit comments