private updateQueryString(): void {
const url = new URL(this.form.action);
+ url.search += url.search !== "" ? "&" : "?";
+ const parameters: string[][] = [];
new FormData(this.form).forEach((value, key) => {
- if (value.toString()) {
- url.search += url.search !== "" ? "&" : "?";
- url.search += encodeURIComponent(key) + "=" + encodeURIComponent(value.toString());
+ if (value.toString().trim()) {
+ parameters.push([key, value.toString().trim()]);
}
});
+ url.search += new URLSearchParams(parameters);
window.history.replaceState({}, document.title, url.toString());
}
function submit(form: HTMLFormElement, input: HTMLInputElement): void {
const url = new URL(form.action);
url.search += url.search !== "" ? "&" : "?";
- url.search += "q=" + encodeURIComponent(input.value.trim());
-
- parameters.forEach((value, key) => {
- url.search += "&" + encodeURIComponent(key) + "=" + encodeURIComponent(value);
- });
-
+ url.search += new URLSearchParams([["q", input.value.trim()], ...Array.from(parameters)]).toString();
window.location.href = url.toString();
}
}
updateQueryString() {
const url = new URL(this.form.action);
+ url.search += url.search !== "" ? "&" : "?";
+ const parameters = [];
new FormData(this.form).forEach((value, key) => {
- if (value.toString()) {
- url.search += url.search !== "" ? "&" : "?";
- url.search += encodeURIComponent(key) + "=" + encodeURIComponent(value.toString());
+ if (value.toString().trim()) {
+ parameters.push([key, value.toString().trim()]);
}
});
+ url.search += new URLSearchParams(parameters);
window.history.replaceState({}, document.title, url.toString());
}
getFormData() {
function submit(form, input) {
const url = new URL(form.action);
url.search += url.search !== "" ? "&" : "?";
- url.search += "q=" + encodeURIComponent(input.value.trim());
- parameters.forEach((value, key) => {
- url.search += "&" + encodeURIComponent(key) + "=" + encodeURIComponent(value);
- });
+ url.search += new URLSearchParams([["q", input.value.trim()], ...Array.from(parameters)]).toString();
window.location.href = url.toString();
}
});