From 51378e0f257fbc97c234223304c58826485ea7cc Mon Sep 17 00:00:00 2001 From: Mark Cottman-Fields Date: Sun, 27 Apr 2014 12:10:17 +1000 Subject: [PATCH] change to uri encoding --- src/common/functions.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/functions.js b/src/common/functions.js index ed14b20a..84facd5a 100644 --- a/src/common/functions.js +++ b/src/common/functions.js @@ -309,7 +309,19 @@ if (!Array.prototype.filter) { this.toKeyValue = function toKeyValue(obj) { var parts = []; angular.forEach(obj, function (value, key) { - parts.push(encodeUriQuery(key, true) + (value === true ? '' : '=' + encodeUriQuery(value, true))); + + // only add key value pair if value is not undefined, not null, and is not an empty string + var valueIsUndefined = value == undefined; + var valueIsNull = value == null; + var valueIsEmptyString = typeof(value) === "string" && value.length < 1; + + if(!valueIsUndefined && !valueIsNull && !valueIsEmptyString){ + var encodedKey = encodeUriQuery(key, /* encode spaces */ true); + // if value is true, just include the key without a value + // TODO: why is this done? + var encodedValue = value === true ? '' : '=' + encodeUriQuery(value, /* encode spaces */ true); + parts.push(encodedKey + encodedValue); + } }); return parts.length ? parts.join('&') : ''; };