File tree 2 files changed +11
-0
lines changed
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);
90
90
for ( var i = 0 ; i < 256 ; ++ i )
91
91
hexTable [ i ] = '%' + ( ( i < 16 ? '0' : '' ) + i . toString ( 16 ) ) . toUpperCase ( ) ;
92
92
QueryString . escape = function ( str ) {
93
+ // replaces encodeURIComponent
94
+ // http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4
95
+ str = '' + str ;
93
96
var len = str . length ;
94
97
var out = '' ;
95
98
var i , c ;
Original file line number Diff line number Diff line change @@ -138,6 +138,14 @@ qsWeirdObjects.forEach(function(testCase) {
138
138
assert . equal ( testCase [ 1 ] , qs . stringify ( testCase [ 0 ] ) ) ;
139
139
} ) ;
140
140
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
+
141
149
// nested
142
150
var f = qs . stringify ( {
143
151
a : 'b' ,
You can’t perform that action at this time.
0 commit comments