From 477649900c679f9abfc60d2ce3c4e715a6f3d2e1 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 16 Jan 2020 08:11:19 +0100 Subject: [PATCH] js: Also adjust `utils.removeUrlParams()`.. ..and properly handle flags in `utils.addUrlParams()` refs #4056 --- public/js/icinga/utils.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index 8c9ac74fa..34aaa4d18 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -132,21 +132,23 @@ newparams = parts.params; $.each(params, function (key, value) { - // We overwrite existing params - newparams[encodeURIComponent(key)] = encodeURIComponent(value); + // We overwrite existing params + newparams[encodeURIComponent(key)] = typeof value === 'string' + ? encodeURIComponent(value) + : null; }); if (Object.keys(newparams).length) { var queryString = '?'; $.each(newparams, function (key, value) { - if (queryString !== '?') { - queryString += '&'; - } + if (queryString !== '?') { + queryString += '&'; + } - queryString += key; - if (value !== null) { - queryString += '=' + value; - } + queryString += key; + if (value !== null) { + queryString += '=' + value; + } }); result += queryString; } @@ -165,7 +167,7 @@ newparams = parts.params; $.each(params, function (idx, key) { - delete newparams[key]; + delete newparams[encodeURIComponent(key)]; }); if (Object.keys(newparams).length) { @@ -175,9 +177,9 @@ queryString += '&'; } - queryString += encodeURIComponent(key); + queryString += key; if (value !== null) { - queryString += '=' + encodeURIComponent(value); + queryString += '=' + value; } }); result += queryString;