File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,9 @@ var hexTable = new Array(256);
9090for ( var i = 0 ; i < 256 ; ++ i )
9191 hexTable [ i ] = '%' + ( ( i < 16 ? '0' : '' ) + i . toString ( 16 ) ) . toUpperCase ( ) ;
9292QueryString . escape = function ( str ) {
93+ // replaces encodeURIComponent
94+ // http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4
95+ str = '' + str ;
9396 var len = str . length ;
9497 var out = '' ;
9598 var i , c ;
Original file line number Diff line number Diff line change @@ -138,6 +138,14 @@ qsWeirdObjects.forEach(function(testCase) {
138138 assert . equal ( testCase [ 1 ] , qs . stringify ( testCase [ 0 ] ) ) ;
139139} ) ;
140140
141+ // coerce numbers to string
142+ assert . strictEqual ( 'foo=0' , qs . stringify ( { foo : 0 } ) ) ;
143+ assert . strictEqual ( 'foo=0' , qs . stringify ( { foo : - 0 } ) ) ;
144+ assert . strictEqual ( 'foo=3' , qs . stringify ( { foo : 3 } ) ) ;
145+ assert . strictEqual ( 'foo=-72.42' , qs . stringify ( { foo : - 72.42 } ) ) ;
146+ assert . strictEqual ( 'foo=' , qs . stringify ( { foo : NaN } ) ) ;
147+ assert . strictEqual ( 'foo=' , qs . stringify ( { foo : Infinity } ) ) ;
148+
141149// nested
142150var f = qs . stringify ( {
143151 a : 'b' ,
You can’t perform that action at this time.
0 commit comments