@@ -143,8 +143,6 @@ test('parse()', function (t) {
143
143
st . end ( ) ;
144
144
} ) ;
145
145
146
- t . deepEqual ( qs . parse ( 'a[b]=c&a=d' ) , { a : { b : 'c' , d : true } } , 'can add keys to objects' ) ;
147
-
148
146
t . test ( 'correctly prunes undefined values when converting an array to an object' , function ( st ) {
149
147
st . deepEqual ( qs . parse ( 'a[2]=b&a[99999999]=c' ) , { a : { '2' : 'b' , '99999999' : 'c' } } ) ;
150
148
st . end ( ) ;
@@ -433,7 +431,45 @@ test('parse()', function (t) {
433
431
st . end ( ) ;
434
432
} ) ;
435
433
436
- t . test ( 'can return plain objects' , function ( st ) {
434
+ t . test ( 'params starting with a starting bracket' , function ( st ) {
435
+ st . deepEqual ( qs . parse ( '[=toString' ) , { } ) ;
436
+ st . end ( ) ;
437
+ } ) ;
438
+
439
+ t . test ( 'params starting with a starting bracket' , function ( st ) {
440
+ st . deepEqual ( qs . parse ( '[=toString' ) , { } ) ;
441
+ st . end ( ) ;
442
+ } ) ;
443
+
444
+ t . test ( 'add keys to objects' , function ( st ) {
445
+ st . deepEqual (
446
+ qs . parse ( 'a[b]=c&a=d' ) ,
447
+ { a : { b : 'c' , d : true } } ,
448
+ 'can add keys to objects'
449
+ ) ;
450
+
451
+ st . deepEqual (
452
+ qs . parse ( 'a[b]=c&a=toString' ) ,
453
+ { a : { b : 'c' } } ,
454
+ 'can not overwrite prototype'
455
+ ) ;
456
+
457
+ st . deepEqual (
458
+ qs . parse ( 'a[b]=c&a=toString' , { allowPrototypes : true } ) ,
459
+ { a : { b : 'c' , toString : true } } ,
460
+ 'can overwrite prototype with allowPrototypes true'
461
+ ) ;
462
+
463
+ st . deepEqual (
464
+ qs . parse ( 'a[b]=c&a=toString' , { plainObjects : true } ) ,
465
+ { a : { b : 'c' , toString : true } } ,
466
+ 'can overwrite prototype with plainObjects true'
467
+ ) ;
468
+
469
+ st . end ( ) ;
470
+ } ) ;
471
+
472
+ t . test ( 'can return null objects' , { skip : ! Object . create } , function ( st ) {
437
473
var expected = Object . create ( null ) ;
438
474
expected . a = Object . create ( null ) ;
439
475
expected . a . b = 'c' ;
0 commit comments