fix: issue 23, handle external URLs in avatar rendering

This commit is contained in:
Lonneke Vuur
2025-06-05 10:26:51 +02:00
parent c9a9779e79
commit 1b2389d618

View File

@@ -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}`;
};