From 3bc27a505f88124021f69cb365d79cf11bb9fda9 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 16 Dec 2023 18:58:31 +0100 Subject: [PATCH] [UI] setUrlArgs should remove args when value == null. --- .../backend/http/webapp/src/utils/Url.vue | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/platypush/backend/http/webapp/src/utils/Url.vue b/platypush/backend/http/webapp/src/utils/Url.vue index 3f667437c..4a7e17d9e 100644 --- a/platypush/backend/http/webapp/src/utils/Url.vue +++ b/platypush/backend/http/webapp/src/utils/Url.vue @@ -22,10 +22,22 @@ export default { }, setUrlArgs(args) { - args = {...this.getUrlArgs(), ...args} - window.location.href = ( - `${window.location.pathname}#${this.parseUrlFragment()}?${this.fragmentFromArgs(args)}` - ) + const curArgs = this.getUrlArgs() + args = Object.entries(args) + .reduce((acc, [key, value]) => { + if (value != null) + acc[key] = value + else if (curArgs[key] != null) + delete curArgs[key] + return acc + }, {}) + + args = {...curArgs, ...args} + let location = `${window.location.pathname}#${this.parseUrlFragment()}` + if (Object.keys(args).length) + location += `?${this.fragmentFromArgs(args)}` + + window.location.href = location }, fragmentFromArgs(args) {