web/user: revert truncate behaviour for application description

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2023-02-15 11:16:14 +01:00
parent d945d30cda
commit ade397fc24
2 changed files with 16 additions and 2 deletions

View File

@ -29,6 +29,20 @@ export function convertToTitle(text: string): string {
});
}
/**
* Truncate a string based on maximum word count
*/
export function truncateWords(string: string, length = 10): string {
string = string || "";
const array = string.trim().split(" ");
const ellipsis = array.length > length ? "..." : "";
return array.slice(0, length).join(" ") + ellipsis;
}
/**
* Truncate a string based on character count
*/
export function truncate(string: string, length = 10): string {
return string.length > length ? `${string.substring(0, length)}...` : string;
}