0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 01:22:07 +01:00

Only serialise the form data in SwapController if the method is GET

This commit is contained in:
Sage Abdullah 2024-07-17 11:16:14 +01:00 committed by Thibaud Colas
parent f7c7e5fbd4
commit a0117bb6b3

View File

@ -219,12 +219,12 @@ export class SwapController extends Controller<
const form = this.formElement;
const data = new FormData(form);
let url = this.srcValue;
// serialise the form to a query string if it's a GET request
// cast as any to avoid https://github.com/microsoft/TypeScript/issues/43797
const searchParams = new URLSearchParams(data as any);
const queryString = '?' + searchParams.toString();
const url =
form.method === 'get' ? this.srcValue + queryString : this.srcValue;
if (form.method === 'get') {
// cast as any to avoid https://github.com/microsoft/TypeScript/issues/43797
url += '?' + new URLSearchParams(data as any).toString();
}
this.replace(url, data);
}