DEV: Modernise discovery controller query parameter construction (#17927)
Using `URLSearchParams` means that we don't have to manually encode/join strings
This commit is contained in:
parent
3a37a7f6b4
commit
55f34c45c6
|
@ -45,17 +45,19 @@ export default Controller.extend({
|
||||||
|
|
||||||
url += "/top";
|
url += "/top";
|
||||||
|
|
||||||
let queryParams = this.router.currentRoute.queryParams;
|
const urlSearchParams = new URLSearchParams();
|
||||||
queryParams.period = period;
|
|
||||||
if (Object.keys(queryParams).length) {
|
for (const [key, value] of Object.entries(
|
||||||
url =
|
this.router.currentRoute.queryParams
|
||||||
`${url}?` +
|
)) {
|
||||||
Object.keys(queryParams)
|
if (typeof value !== "undefined") {
|
||||||
.map((key) => `${key}=${queryParams[key]}`)
|
urlSearchParams.set(key, value);
|
||||||
.join("&");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
urlSearchParams.set("period", period);
|
||||||
|
|
||||||
|
return `${url}?${urlSearchParams.toString()}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
Loading…
Reference in New Issue