fix: broken google account avatar fix (#13892)

* fix: broken google account avatar fix

* fix: use zod for checking absolute url

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
This commit is contained in:
Rinku Chaudhari
2024-02-29 19:59:23 +00:00
committed by GitHub
co-authored by Udit Takkar Udit Takkar
parent aedc88f975
commit 81c0b1ffe9
+9 -1
View File
@@ -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