From bbd6d0b4e550d90635d8a4739c9554269f1a31c1 Mon Sep 17 00:00:00 2001 From: JalonSolov Date: Fri, 19 Jun 2020 19:39:55 -0400 Subject: [PATCH] vweb: ignore url params on static files --- vlib/vweb/vweb.v | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 10ba8f5690..2ddb4297ee 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -270,9 +270,14 @@ fn handle_conn(conn net.Socket, mut app T) { //continue } - // Serve a static file if it's one - static_file := app.vweb.static_files[app.vweb.req.url] - mime_type := app.vweb.static_mime_types[app.vweb.req.url] + // Serve a static file if it is one + // TODO: handle url parameters properly - for now, ignore them + mut static_file_name := app.vweb.req.url + if static_file_name.contains('?') { + static_file_name = static_file_name.all_before('?') + } + static_file := app.vweb.static_files[static_file_name] + mime_type := app.vweb.static_mime_types[static_file_name] if static_file != '' && mime_type != '' { data := os.read_file(static_file) or {