forked from platypush/platypush
[UI] setUrlArgs should remove args when value == null.
This commit is contained in:
parent
065f7d74a5
commit
3bc27a505f
1 changed files with 16 additions and 4 deletions
|
@ -22,10 +22,22 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
setUrlArgs(args) {
|
setUrlArgs(args) {
|
||||||
args = {...this.getUrlArgs(), ...args}
|
const curArgs = this.getUrlArgs()
|
||||||
window.location.href = (
|
args = Object.entries(args)
|
||||||
`${window.location.pathname}#${this.parseUrlFragment()}?${this.fragmentFromArgs(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) {
|
fragmentFromArgs(args) {
|
||||||
|
|
Loading…
Reference in a new issue