@@ -188,7 +188,7 @@ var parseObject = function (chain, val, options, valuesParsed) {
188
188
) {
189
189
obj = [ ] ;
190
190
obj [ index ] = leaf ;
191
- } else {
191
+ } else if ( cleanRoot !== '__proto__' ) {
192
192
obj [ cleanRoot ] = leaf ;
193
193
}
194
194
}
@@ -329,6 +329,7 @@ var arrayPrefixGenerators = {
329
329
} ;
330
330
331
331
var isArray = Array . isArray ;
332
+ var split = String . prototype . split ;
332
333
var push = Array . prototype . push ;
333
334
var pushToArray = function ( arr , valueOrArray ) {
334
335
push . apply ( arr , isArray ( valueOrArray ) ? valueOrArray : [ valueOrArray ] ) ;
@@ -392,6 +393,14 @@ var stringify = function stringify(
392
393
if ( typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils . isBuffer ( obj ) ) {
393
394
if ( encoder ) {
394
395
var keyValue = encodeValuesOnly ? prefix : encoder ( prefix , defaults . encoder , charset ) ;
396
+ if ( generateArrayPrefix === 'comma' && encodeValuesOnly ) {
397
+ var valuesArray = split . call ( String ( obj ) , ',' ) ;
398
+ var valuesJoined = '' ;
399
+ for ( var i = 0 ; i < valuesArray . length ; ++ i ) {
400
+ valuesJoined += ( i === 0 ? '' : ',' ) + formatter ( encoder ( valuesArray [ i ] , defaults . encoder , charset ) ) ;
401
+ }
402
+ return [ formatter ( keyValue ) + '=' + valuesJoined ] ;
403
+ }
395
404
return [ formatter ( keyValue ) + '=' + formatter ( encoder ( obj , defaults . encoder , charset ) ) ] ;
396
405
}
397
406
return [ formatter ( prefix ) + '=' + formatter ( String ( obj ) ) ] ;
@@ -411,16 +420,17 @@ var stringify = function stringify(
411
420
objKeys = sort ? keys . sort ( sort ) : keys ;
412
421
}
413
422
414
- for ( var i = 0 ; i < objKeys . length ; ++ i ) {
415
- var key = objKeys [ i ] ;
423
+ for ( var j = 0 ; j < objKeys . length ; ++ j ) {
424
+ var key = objKeys [ j ] ;
425
+ var value = typeof key === 'object' && typeof key . value !== 'undefined' ? key . value : obj [ key ] ;
416
426
417
427
if ( skipNulls && obj [ key ] === null ) {
418
428
continue ;
419
429
}
420
430
421
431
if ( isArray ( obj ) ) {
422
432
pushToArray ( values , stringify (
423
- obj [ key ] ,
433
+ value ,
424
434
typeof generateArrayPrefix === 'function' ? generateArrayPrefix ( prefix , key ) : prefix ,
425
435
generateArrayPrefix ,
426
436
strictNullHandling ,
@@ -436,7 +446,7 @@ var stringify = function stringify(
436
446
) ) ;
437
447
} else {
438
448
pushToArray ( values , stringify (
439
- obj [ key ] ,
449
+ value ,
440
450
prefix + ( allowDots ? '.' + key : '[' + key + ']' ) ,
441
451
generateArrayPrefix ,
442
452
strictNullHandling ,
@@ -461,7 +471,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
461
471
return defaults ;
462
472
}
463
473
464
- if ( opts . encoder !== null && opts . encoder !== undefined && typeof opts . encoder !== 'function' ) {
474
+ if ( opts . encoder !== null && typeof opts . encoder !== ' undefined' && typeof opts . encoder !== 'function' ) {
465
475
throw new TypeError ( 'Encoder has to be a function.' ) ;
466
476
}
467
477
@@ -752,6 +762,7 @@ var encode = function encode(str, defaultEncoder, charset) {
752
762
753
763
i += 1 ;
754
764
c = 0x10000 + ( ( ( c & 0x3FF ) << 10 ) | ( string . charCodeAt ( i ) & 0x3FF ) ) ;
765
+ /* eslint operator-linebreak: [2, "before"] */
755
766
out += hexTable [ 0xF0 | ( c >> 18 ) ]
756
767
+ hexTable [ 0x80 | ( ( c >> 12 ) & 0x3F ) ]
757
768
+ hexTable [ 0x80 | ( ( c >> 6 ) & 0x3F ) ]
0 commit comments