diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-01 15:35:07 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-01 15:59:30 +1000 |
commit | 7faf6e75614f4c2818f4f30a0014ee97d4244bfb (patch) | |
tree | 52b925703d5eadb48c5c88bdc1150d92a3d8e152 /src/cdn | |
parent | Better embed handling (diff) | |
download | server-7faf6e75614f4c2818f4f30a0014ee97d4244bfb.tar.xz |
Slightly better embeds
Diffstat (limited to '')
-rw-r--r-- | src/cdn/routes/external.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cdn/routes/external.ts b/src/cdn/routes/external.ts index 405e665e..33528a7b 100644 --- a/src/cdn/routes/external.ts +++ b/src/cdn/routes/external.ts @@ -77,6 +77,10 @@ router.get("/resize/:url", async (req: Request, res: Response) => { throw new HTTPError("Couldn't fetch website"); } + if (response.headers.get("content-type")?.indexOf("image") === -1) { + throw new HTTPError("Content type is not image."); + } + const resizedBuffer = await sharp(buffer) .resize(parseInt(width as string), parseInt(height as string), { fit: "inside", |