fix: avatar URL breaking for team/orgs in BookerEmbed atom (#27424)

* fix: avatar URL breaking for team/orgs in booker embed

* fix: api v2 breaking because of type mismatch

* fix: atoms build

* chore: implement PR feedback
This commit is contained in:
Rajiv Sahal authored and GitHub committed 2026-02-03 17:19:48 +00:00
1 parent 2ccff0aead
commit efcbc3a07b
3 files changed
+46 -20

No files matched your search

+8 -9
View File
@@ -1,21 +1,20 @@
import { z } from "zod";
import { AVATAR_FALLBACK, CAL_URL } from "@calcom/lib/constants";
import type { User } from "@calcom/prisma/client";
import { z } from "zod";
export const getAbsoluteAvatarUrl = (url: string): string => {
const isAbsolute = z.string().url().safeParse(url).success;
return isAbsolute ? url : CAL_URL + url;
};
/**
* Gives an organization aware avatar url for a user
* It ensures that the wrong avatar isn't fetched by ensuring that organizationId is always passed
* It should always return a fully formed url
*/
export const getUserAvatarUrl = (user: Pick<User, "avatarUrl"> | undefined) => {
export const getUserAvatarUrl = (user: Pick<User, "avatarUrl"> | undefined): string => {
if (user?.avatarUrl) {
const isAbsoluteUrl = z.string().url().safeParse(user.avatarUrl).success;
if (isAbsoluteUrl) {
return user.avatarUrl;
} else {
return CAL_URL + user.avatarUrl;
}
return getAbsoluteAvatarUrl(user.avatarUrl);
}
return CAL_URL + AVATAR_FALLBACK;
};