From 1b2389d6186d6340e12c08ac4b72aca1cf7d0c1d Mon Sep 17 00:00:00 2001 From: Lonneke Vuur Date: Thu, 5 Jun 2025 10:26:51 +0200 Subject: [PATCH] fix: issue 23, handle external URLs in avatar rendering --- apps/web/src/utils/helpers.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/web/src/utils/helpers.ts b/apps/web/src/utils/helpers.ts index 672ac162..9db6af73 100644 --- a/apps/web/src/utils/helpers.ts +++ b/apps/web/src/utils/helpers.ts @@ -45,6 +45,10 @@ export const formatMemberDisplayName = ( return localPart.replace(/[_-]/g, "."); }; -export const getAvatarUrl = (key: string) => { - return `${env("NEXT_PUBLIC_STORAGE_URL")}/${env("NEXT_PUBLIC_AVATAR_BUCKET_NAME")}/${key}`; +export const getAvatarUrl = (imageOrKey: string) => { + if (imageOrKey.startsWith("http://") || imageOrKey.startsWith("https://")) { + return imageOrKey; + } + + return `${env("NEXT_PUBLIC_STORAGE_URL")}/${env("NEXT_PUBLIC_AVATAR_BUCKET_NAME")}/${imageOrKey}`; };