gitlab-org--gitlab-foss/app/assets/javascripts/lib/utils/forms.js
minghuan lei aa137fd39f Add repo-refs control for search page
- only in blobs result
2019-08-09 16:32:17 +00:00

12 lines
417 B
JavaScript

export const serializeFormEntries = entries =>
entries.reduce((acc, { name, value }) => Object.assign(acc, { [name]: value }), {});
export const serializeForm = form => {
const fdata = new FormData(form);
const entries = Array.from(fdata.keys()).map(key => {
const val = fdata.getAll(key);
return { name: key, value: val.length === 1 ? val[0] : val };
});
return serializeFormEntries(entries);
};