1
0
Fork 0

clean up avatar url allowed code

This commit is contained in:
Skip R. 2023-04-26 18:22:56 -07:00
parent f9f28810a2
commit c0b8ee2427
1 changed files with 4 additions and 4 deletions

View File

@ -5,11 +5,11 @@ import { redirect, useRouter } from "next/navigation";
import { ensureJpg } from "@/image";
function avatarUrlAllowed(url: URL): boolean {
let notGithub = url.hostname !== "avatars.githubusercontent.com";
let notDiscord = url.hostname !== "cdn.discordapp.com";
let github = url.hostname === "avatars.githubusercontent.com";
let discord = url.hostname === "cdn.discordapp.com";
if (!notDiscord && !url.pathname.startsWith("/avatars")) return false;
return !(notGithub && notDiscord);
if (discord && !url.pathname.startsWith("/avatars")) return false;
return github || discord;
}
export default async function Page({