chore: Minor fix

This commit is contained in:
iamsivin
2024-11-21 12:43:54 +05:30
parent 75cf5322c9
commit edfb1029a7
5 changed files with 14 additions and 76 deletions
@@ -19,19 +19,3 @@ export const checkFileSizeLimit = (file, maximumUploadLimit) => {
const fileSizeInMB = fileSizeInMegaBytes(fileSize);
return fileSizeInMB <= maximumUploadLimit;
};
export const fileNameWithEllipsis = (file, maxLength = 26, ellipsis = '…') => {
const fullName = file?.filename ?? file?.name ?? 'Untitled';
const dotIndex = fullName.lastIndexOf('.');
if (dotIndex === -1) return fullName;
const [name, extension] = [
fullName.slice(0, dotIndex),
fullName.slice(dotIndex),
];
if (name.length <= maxLength) return fullName;
return `${name.slice(0, maxLength)}${ellipsis}${extension}`;
};