Skip to content
Snippets Groups Projects
Commit f791ceb9 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

update file validation

parent 75b48d81
No related branches found
No related tags found
No related merge requests found
Pipeline #6580 passed
......@@ -35,6 +35,16 @@ const allowedFileTypes = [
'application/x-zip',
];
const allowedFileEnds = ['.zip', '.jpeg', '.jpg', '.jpe', '.png'];
function validateFileName(fileNameToValidate) {
return (
allowedFileEnds.find((typeName) => {
return fileNameToValidate.toLowerCase().endsWith(typeName);
}).length > 0
);
}
// in megabytes
const maxFileSize = 50;
......@@ -211,7 +221,7 @@ class AddSolutionForm extends Component {
!description ||
(!file
? false
: !allowedFileTypes.includes(file.type) ||
: validateFileName(file.name) ||
file.size > maxFileSize * 1024 ** 2)
}
inverted
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment