Fix: formatFileName function cant truncate when numberToTruncate are bigger than name length
This commit is contained in:
parent
a88193aeee
commit
d091bf9611
1 changed files with 3 additions and 0 deletions
|
|
@ -2,6 +2,9 @@ export default function formatFileName(
|
||||||
name: string,
|
name: string,
|
||||||
numberToTruncate: number = 29,
|
numberToTruncate: number = 29,
|
||||||
): string {
|
): string {
|
||||||
|
if (name[numberToTruncate] === undefined) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
const fileExtension = name.split(".").pop(); // Get the file extension
|
const fileExtension = name.split(".").pop(); // Get the file extension
|
||||||
const baseName = name.slice(0, name.lastIndexOf(".")); // Get the base name without the extension
|
const baseName = name.slice(0, name.lastIndexOf(".")); // Get the base name without the extension
|
||||||
if (baseName.length > 6) {
|
if (baseName.length > 6) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue