fix: handle external URLs in avatar rendering (#23) (#32)

* fix: issue 23, handle external URLs in avatar rendering

* fix: add google to the remote patterns

---------

Co-authored-by: Henry <henry_ball@hotmail.co.uk>
This commit is contained in:
Lonneke
2025-06-05 14:10:38 +02:00
committed by GitHub
parent 6eb17529f1
commit f88bd82044
4 changed files with 18 additions and 5 deletions

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