Skip to content

Scheduling infrastructure for absolutely everyone.

fix: broken google account avatar fix (#13892)

Rinku Chaudhari81c0b1ffe9c3
diff --git a/packages/lib/getAvatarUrl.ts b/packages/lib/getAvatarUrl.ts
index b0d7d62ebc9..d2492edf9a3 100644
--- a/packages/lib/getAvatarUrl.ts
+++ b/packages/lib/getAvatarUrl.ts
@@ -1,3 +1,5 @@
+import { z } from "zod";
+
import { AVATAR_FALLBACK, CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
import type { Team, User } from "@calcom/prisma/client";
import type { UserProfile } from "@calcom/types/UserProfile";
@@ -16,7 +18,13 @@ export const getUserAvatarUrl = (
| undefined
) => {
if (user?.avatarUrl) {
- return CAL_URL + user.avatarUrl;
+ const isAbsoluteUrl = z.string().url().safeParse(user.avatarUrl).success;
+
+ if (isAbsoluteUrl) {
+ return user.avatarUrl;
+ } else {
+ return CAL_URL + user.avatarUrl;
+ }
}
if (!user?.username) return CAL_URL + AVATAR_FALLBACK;
// avatar.png automatically redirects to fallback avatar if user doesn't have one