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 <[email protected]> Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
1 file changed
+9
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user