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) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue