fix: added check to upload .md files correctly (#8017)

Added check to upload file type if file.type does not exist
This commit is contained in:
Lucas Oliveira 2025-05-13 16:50:53 -03:00 • committed by GitHub
commit 0e6fc94dad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,12 +38,10 @@ const useUploadFile = ({
for (const file of filesToUpload) { for (const file of filesToUpload) {
validateFileSize(file); validateFileSize(file);
// Check if file extension is allowed // Check if file extension is allowed
const fileExtension = file.type const fileExtension = file.name.split(".").pop()?.toLowerCase();
? file.name.split(".").pop()?.toLowerCase() if (!fileExtension || (types && !types.includes(fileExtension))) {
: null;
if (types && (!fileExtension || !types.includes(fileExtension))) {
throw new Error( throw new Error(
`File type not allowed. Allowed types: ${types.join(", ")}`, `File type ${fileExtension} not allowed. Allowed types: ${types?.join(", ")}`,
); );
} }
if (!fileExtension) { if (!fileExtension) {