From: Jeremiah Senkpiel Date: Fri, 20 Mar 2015 01:33:04 +0000 (-0400) Subject: querystring: fix broken stringifyPrimitive X-Git-Tag: v1.6.1~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9aec2b7167a08dc88141fbe3be1c498f8c5b061;p=platform%2Fupstream%2Fnodejs.git 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 Reviewed-By: Brian White --- diff --git a/lib/querystring.js b/lib/querystring.js index f0d473a..09220a9 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -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 '';