fix: ensure truncated result stays within maxLength limit

This commit is contained in:
YeonGyu-Kim
2026-02-07 19:13:35 +09:00
parent a0201e17b9
commit f94ae2032c
2 changed files with 8 additions and 16 deletions
+1 -9
View File
@@ -1,11 +1,3 @@
/**
* Truncates a description string to a maximum character length.
* If truncated, appends "..." to indicate continuation.
*
* @param description - The description string to truncate
* @param maxLength - Maximum character length (default: 120)
* @returns Truncated description with "..." appended if it was truncated
*/
export function truncateDescription(description: string, maxLength: number = 120): string {
if (!description) {
return description
@@ -15,5 +7,5 @@ export function truncateDescription(description: string, maxLength: number = 120
return description
}
return description.slice(0, maxLength) + "..."
return description.slice(0, maxLength - 3) + "..."
}