From ebed818824bde0770a094cf84a077a0d9c68a940 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 6 Mar 2021 18:17:43 +0100 Subject: [PATCH] Respond with a 404 when requested file is not found instead of crashing --- src/controllers/GiteaRepoLatestReleaseController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/GiteaRepoLatestReleaseController.ts b/src/controllers/GiteaRepoLatestReleaseController.ts index b749860..e52ee25 100644 --- a/src/controllers/GiteaRepoLatestReleaseController.ts +++ b/src/controllers/GiteaRepoLatestReleaseController.ts @@ -32,6 +32,8 @@ export default class GiteaRepoLatestReleaseController extends Controller { data += c; }); r.on('end', async () => { + if (r.statusCode === 404) return next(new NotFoundHttpError('file', req.url)); + try { const releases = JSON.parse(data);