Fixed bug where user could create empty app or bookmark which was causing page to go blank

This commit is contained in:
Paweł Malak
2022-03-25 13:16:57 +01:00
parent 668edb03d3
commit 0b3eb2e87f
5 changed files with 29 additions and 7 deletions

View File

@@ -69,6 +69,17 @@ export const BookmarksForm = ({
const formSubmitHandler = (e: FormEvent): void => {
e.preventDefault();
for (let field of ['name', 'url', 'icon'] as const) {
if (/^ +$/.test(formData[field])) {
createNotification({
title: 'Error',
message: `Field cannot be empty: ${field}`,
});
return;
}
}
const createFormData = (): FormData => {
const data = new FormData();
if (customIcon) {