From c731615dbbf1d3ec9088fb23db58e8e6064d4a7e Mon Sep 17 00:00:00 2001 From: "Ian M. Jones" Date: Sun, 8 Mar 2020 14:41:59 +0000 Subject: [PATCH] vweb: cater for trailing slashes being used in handle_static call --- vlib/vweb/vweb.v | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 3b67d8e083..4cea19aee7 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -347,14 +347,15 @@ pub fn (ctx mut Context) handle_static(directory_path string) bool { return false } - dir_path := directory_path.trim_space() + dir_path := directory_path.trim_space().trim_right('/') mut mount_path := '' if dir_path != '.' && os.is_dir(dir_path) { - mount_path = '/' + dir_path + // Mount point hygene, "./assets" => "/assets". + mount_path = '/' + dir_path.trim_left('.').trim('/') } - ctx.scan_static_directory(directory_path, mount_path) + ctx.scan_static_directory(dir_path, mount_path) return true }