File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ function compact(obj) {
162162
163163 for ( var i in obj ) {
164164 if ( hasOwnProperty . call ( obj , i ) ) {
165- ret . push ( obj [ i ] ) ;
165+ ret . push ( restoreProto ( obj [ i ] ) ) ;
166166 }
167167 }
168168
@@ -183,10 +183,7 @@ function compact(obj) {
183183
184184function restoreProto ( obj ) {
185185 if ( ! Object . create ) return obj ;
186- if ( isArray ( obj ) ) {
187- obj . __proto__ = Object . prototype ;
188- return obj ;
189- }
186+ if ( isArray ( obj ) ) return obj ;
190187 if ( obj && 'object' != typeof obj ) return obj ;
191188
192189 for ( var key in obj ) {
Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ describe('qs.parse()', function(){
105105 expect ( qs . parse ( 'foo[base64]=RAWR' ) ) . to . eql ( { foo : { base64 : 'RAWR' } } ) ;
106106 expect ( qs . parse ( 'foo[64base]=RAWR' ) ) . to . eql ( { foo : { '64base' : 'RAWR' } } ) ;
107107 } )
108+
109+ it ( 'should support toString() with an array of objects' , function ( ) {
110+ expect ( qs . parse ( 'foo[0][bar]=baz&foo[1][bat]=boo' ) . foo . toString ( ) ) . to . eql ( '[object Object],[object Object]' ) ;
111+ } )
108112
109113 it ( 'should expand to an array when dupliate keys are present' , function ( ) {
110114 expect ( qs . parse ( 'items=bar&items=baz&items=raz' ) )
You can’t perform that action at this time.
0 commit comments