From f833188234f68ed921541d50a0cd2b45d26d5827 Mon Sep 17 00:00:00 2001 From: sandbankdisperser <134144212+sandbankdisperser@users.noreply.github.com> Date: Sun, 21 May 2023 15:23:43 +0200 Subject: [PATCH] vweb: return 404 on file not found (#18219) --- vlib/vweb/vweb.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index cca1156957..ac0810c2be 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -256,6 +256,10 @@ pub fn (mut ctx Context) json_pretty[T](j T) Result { // TODO - test // Response HTTP_OK with file as payload pub fn (mut ctx Context) file(f_path string) Result { + if !os.exists(f_path) { + eprintln('[vweb] file ${f_path} does not exist') + return ctx.not_found() + } ext := os.file_ext(f_path) data := os.read_file(f_path) or { eprint(err.msg())