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 | 070ce373e90399d9df2a8986e0c7728724163da7 (patch) | |
tree | c629c0f7f9cbf785c0a4b9a43a785c8f530f343b /src/cdn | |
parent | Better embed handling (diff) | |
download | server-070ce373e90399d9df2a8986e0c7728724163da7.tar.xz |
Slightly better embeds
Diffstat (limited to 'src/cdn')
-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", |