Fix: formatFileName function cant truncate when numberToTruncate are bigger than name length

This commit is contained in:
igorrCarvalho 2024-05-30 17:14:39 -03:00
commit d091bf9611

View file

@ -2,6 +2,9 @@ export default function formatFileName(
name: string,
numberToTruncate: number = 29,
): string {
if (name[numberToTruncate] === undefined) {
return name;
}
const fileExtension = name.split(".").pop(); // Get the file extension
const baseName = name.slice(0, name.lastIndexOf(".")); // Get the base name without the extension
if (baseName.length > 6) {