forked from NotNet/gluestick
clean up avatar url allowed code
This commit is contained in:
parent
f9f28810a2
commit
c0b8ee2427
|
@ -5,11 +5,11 @@ import { redirect, useRouter } from "next/navigation";
|
||||||
import { ensureJpg } from "@/image";
|
import { ensureJpg } from "@/image";
|
||||||
|
|
||||||
function avatarUrlAllowed(url: URL): boolean {
|
function avatarUrlAllowed(url: URL): boolean {
|
||||||
let notGithub = url.hostname !== "avatars.githubusercontent.com";
|
let github = url.hostname === "avatars.githubusercontent.com";
|
||||||
let notDiscord = url.hostname !== "cdn.discordapp.com";
|
let discord = url.hostname === "cdn.discordapp.com";
|
||||||
|
|
||||||
if (!notDiscord && !url.pathname.startsWith("/avatars")) return false;
|
if (discord && !url.pathname.startsWith("/avatars")) return false;
|
||||||
return !(notGithub && notDiscord);
|
return github || discord;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
|
|
Loading…
Reference in New Issue