Skip to content

Commit

Permalink
querystring: fix broken stringifyPrimitive
Browse files Browse the repository at this point in the history
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 <rod@vagg.org>
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information
Fishrock123 committed Mar 20, 2015
1 parent a89f5c2 commit c9aec2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ QueryString.escape = function(str) {
};

var stringifyPrimitive = function(v) {
if (typeof v === 'string' || (typeof v === 'number' && isFinite(v)))
if (typeof v === 'string')
return v;
if (typeof v === 'number' && isFinite(v))
return '' + v;
if (typeof v === 'boolean')
return v ? 'true' : 'false';
return '';
Expand Down

0 comments on commit c9aec2b

Please sign in to comment.