Browse Source

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: https://github.com/iojs/io.js/issues/1208
PR-URL: https://github.com/iojs/io.js/pull/1213
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Brian White <mscdex@mscdex.net>
v1.8.0-commit
Jeremiah Senkpiel 10 years ago
parent
commit
c9aec2b716
  1. 4
      lib/querystring.js

4
lib/querystring.js

@ -147,8 +147,10 @@ QueryString.escape = function(str) {
}; };
var stringifyPrimitive = function(v) { var stringifyPrimitive = function(v) {
if (typeof v === 'string' || (typeof v === 'number' && isFinite(v))) if (typeof v === 'string')
return v; return v;
if (typeof v === 'number' && isFinite(v))
return '' + v;
if (typeof v === 'boolean') if (typeof v === 'boolean')
return v ? 'true' : 'false'; return v ? 'true' : 'false';
return ''; return '';

Loading…
Cancel
Save