fix: file extension

This commit is contained in:
StyleZhang 2024-10-16 17:46:26 +08:00
parent ff7a467a1a
commit e232f4cc87

View File

@ -44,9 +44,6 @@ export const fileUpload: FileUpload = ({
}
export const getFileExtension = (fileName: string, fileMimetype: string) => {
if (fileMimetype)
return mime.getExtension(fileMimetype) || ''
if (fileName) {
const fileNamePair = fileName.split('.')
const fileNamePairLength = fileNamePair.length
@ -55,6 +52,9 @@ export const getFileExtension = (fileName: string, fileMimetype: string) => {
return fileNamePair[fileNamePairLength - 1]
}
if (fileMimetype)
return mime.getExtension(fileMimetype) || ''
return ''
}