From bb98d22f7ab1116e2817dc7a96b2343dea97cd08 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Thu, 11 Apr 2024 19:33:59 -0700 Subject: properly show ids --- apps/web/src/lib/utils.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps/web/src') diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index 4f34e990..f7e6d3be 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -19,8 +19,14 @@ export function cleanUrl(url: string) { } export function getIdsFromSource(sourceIds: string[]) { - // This function converts an id from a form of `websiteURL-userID` to just the websiteURL - return sourceIds.map((id) => id.split("-").slice(0, -1).join("-")); + return sourceIds.map((id) => { + const parts = id.split("-"); + if (parts.length > 1) { + return parts.slice(0, -1).join("-"); + } else { + return id; + } + }); } export function generateId() { -- cgit v1.2.3