Skip to content

Commit c9aec2b

Browse files
committed
querystring: fix broken stringifyPrimitive
stringifyPrimitive has always failed to stringify numbers since its introduction in 422d3c9. This went uncaught due to encodeURIComponent's string coercion. Fixes: #1208 PR-URL: #1213 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent a89f5c2 commit c9aec2b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/querystring.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ QueryString.escape = function(str) {
147147
};
148148

149149
var stringifyPrimitive = function(v) {
150-
if (typeof v === 'string' || (typeof v === 'number' && isFinite(v)))
150+
if (typeof v === 'string')
151151
return v;
152+
if (typeof v === 'number' && isFinite(v))
153+
return '' + v;
152154
if (typeof v === 'boolean')
153155
return v ? 'true' : 'false';
154156
return '';

0 commit comments

Comments
 (0)