querystringify
Advanced tools
Comparing version 2.0.0 to 2.1.0
21
index.js
'use strict'; | ||
var has = Object.prototype.hasOwnProperty; | ||
var has = Object.prototype.hasOwnProperty | ||
, undef; | ||
@@ -55,3 +56,5 @@ /** | ||
var pairs = []; | ||
var pairs = [] | ||
, value | ||
, key; | ||
@@ -63,5 +66,15 @@ // | ||
for (var key in obj) { | ||
for (key in obj) { | ||
if (has.call(obj, key)) { | ||
pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key])); | ||
value = obj[key]; | ||
// | ||
// Edge cases where we actually want to encode the value to an empty | ||
// string instead of the stringified value. | ||
// | ||
if (!value && (value === null || value === undef || isNaN(value))) { | ||
value = ''; | ||
} | ||
pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(value)); | ||
} | ||
@@ -68,0 +81,0 @@ } |
{ | ||
"name": "querystringify", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Querystringify - Small, simple but powerful query string parser.", | ||
@@ -34,7 +34,7 @@ "main": "index.js", | ||
"devDependencies": { | ||
"assume": "^2.0.1", | ||
"assume": "^2.1.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.1.1", | ||
"mocha": "^5.2.0", | ||
"pre-commit": "^1.2.2" | ||
} | ||
} |
6539
74