diff --git a/web/src/admin/admin-overview/cards/RecentEventsCard.ts b/web/src/admin/admin-overview/cards/RecentEventsCard.ts index b10d08798..45997a47e 100644 --- a/web/src/admin/admin-overview/cards/RecentEventsCard.ts +++ b/web/src/admin/admin-overview/cards/RecentEventsCard.ts @@ -2,6 +2,7 @@ import "@goauthentik/admin/events/EventInfo"; import { ActionToLabel } from "@goauthentik/admin/events/utils"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { EventWithContext } from "@goauthentik/common/events"; +import { truncate } from "@goauthentik/common/utils"; import "@goauthentik/elements/Tabs"; import "@goauthentik/elements/buttons/Dropdown"; import "@goauthentik/elements/buttons/ModalButton"; @@ -78,7 +79,7 @@ export class RecentEventsCard extends Table { item.user?.username ? html`
${item.user?.username.substring(0, 15)}${truncate(item.user?.username, 15)}
${item.user.on_behalf_of diff --git a/web/src/common/utils.ts b/web/src/common/utils.ts index 27090bcbb..1d26396b1 100644 --- a/web/src/common/utils.ts +++ b/web/src/common/utils.ts @@ -29,12 +29,8 @@ export function convertToTitle(text: string): string { }); } -export function truncate(input?: string, max = 10): string { - input = input || ""; - const array = input.trim().split(" "); - const ellipsis = array.length > max ? "..." : ""; - - return array.slice(0, max).join(" ") + ellipsis; +export function truncate(string: string, length = 10): string { + return string.length > length ? `${string.substring(0, length)}...` : string; } export function camelToSnake(key: string): string { diff --git a/web/src/user/LibraryApplication.ts b/web/src/user/LibraryApplication.ts index 4d3457cb1..6d374dbff 100644 --- a/web/src/user/LibraryApplication.ts +++ b/web/src/user/LibraryApplication.ts @@ -126,7 +126,9 @@ export class LibraryApplication extends AKElement { ${this.application.metaPublisher} -
${truncate(this.application.metaDescription, 35)}
+
+ ${truncate(this.application.metaDescription || "", 35)} +
`; } }