mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
Fixes #755 ### Notes for Reviewers - The max length of the title is set to be `16` - If the length of the title is <16 it returns the original one. - Or else the title will be the first 8 characters (start) and last 8 characters (end) - The truncated file name will look like `start...end` ### Screenshot for reference  --------- Co-authored-by: Catalin Pit <25515812+catalinpit@users.noreply.github.com>
11 lines
258 B
TypeScript
11 lines
258 B
TypeScript
export const truncateTitle = (title: string, maxLength: number = 16) => {
|
|
if (title.length <= maxLength) {
|
|
return title;
|
|
}
|
|
|
|
const start = title.slice(0, maxLength / 2);
|
|
const end = title.slice(-maxLength / 2);
|
|
|
|
return `${start}.....${end}`;
|
|
};
|