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

Merge branch 'master' of git.sch.bme.hu:kszk/devteam/kszkepzes/old/kszkepzes-frontend

parents 29483107 0d8a97d9
No related branches found
No related tags found
No related merge requests found
Pipeline #6687 passed
...@@ -35,6 +35,16 @@ const allowedFileTypes = [ ...@@ -35,6 +35,16 @@ const allowedFileTypes = [
'application/x-zip', '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 // in megabytes
const maxFileSize = 50; const maxFileSize = 50;
...@@ -211,7 +221,7 @@ class AddSolutionForm extends Component { ...@@ -211,7 +221,7 @@ class AddSolutionForm extends Component {
!description || !description ||
(!file (!file
? false ? false
: !allowedFileTypes.includes(file.type) || : !validateFileName(file.name) ||
file.size > maxFileSize * 1024 ** 2) file.size > maxFileSize * 1024 ** 2)
} }
inverted inverted
...@@ -270,7 +280,7 @@ class AddSolutionForm extends Component { ...@@ -270,7 +280,7 @@ class AddSolutionForm extends Component {
!description || !description ||
(!file (!file
? false ? false
: !allowedFileTypes.includes(file.type) || : !validateFileName(file.name) ||
file.size > maxFileSize * 1024 ** 2) file.size > maxFileSize * 1024 ** 2)
} }
onClick={() => { onClick={() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment