@@ -152,8 +152,6 @@ test('parse()', function (t) {
152152 st . end ( ) ;
153153 } ) ;
154154
155- t . deepEqual ( qs . parse ( 'a[b]=c&a=d' ) , { a : { b : 'c' , d : true } } , 'can add keys to objects' ) ;
156-
157155 t . test ( 'correctly prunes undefined values when converting an array to an object' , function ( st ) {
158156 st . deepEqual ( qs . parse ( 'a[2]=b&a[99999999]=c' ) , { a : { 2 : 'b' , 99999999 : 'c' } } ) ;
159157 st . end ( ) ;
@@ -444,6 +442,44 @@ test('parse()', function (t) {
444442 st . end ( ) ;
445443 } ) ;
446444
445+ t . test ( 'params starting with a starting bracket' , function ( st ) {
446+ st . deepEqual ( qs . parse ( '[=toString' ) , { } ) ;
447+ st . end ( ) ;
448+ } ) ;
449+
450+ t . test ( 'params starting with a starting bracket' , function ( st ) {
451+ st . deepEqual ( qs . parse ( '[=toString' ) , { } ) ;
452+ st . end ( ) ;
453+ } ) ;
454+
455+ t . test ( 'add keys to objects' , function ( st ) {
456+ st . deepEqual (
457+ qs . parse ( 'a[b]=c&a=d' ) ,
458+ { a : { b : 'c' , d : true } } ,
459+ 'can add keys to objects'
460+ ) ;
461+
462+ st . deepEqual (
463+ qs . parse ( 'a[b]=c&a=toString' ) ,
464+ { a : { b : 'c' } } ,
465+ 'can not overwrite prototype'
466+ ) ;
467+
468+ st . deepEqual (
469+ qs . parse ( 'a[b]=c&a=toString' , { allowPrototypes : true } ) ,
470+ { a : { b : 'c' , toString : true } } ,
471+ 'can overwrite prototype with allowPrototypes true'
472+ ) ;
473+
474+ st . deepEqual (
475+ qs . parse ( 'a[b]=c&a=toString' , { plainObjects : true } ) ,
476+ { a : { b : 'c' , toString : true } } ,
477+ 'can overwrite prototype with plainObjects true'
478+ ) ;
479+
480+ st . end ( ) ;
481+ } ) ;
482+
447483 t . test ( 'can return null objects' , { skip : ! Object . create } , function ( st ) {
448484 var expected = Object . create ( null ) ;
449485 expected . a = Object . create ( null ) ;
0 commit comments