1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vweb: ignore url params on static files

This commit is contained in:
JalonSolov 2020-06-19 19:39:55 -04:00 committed by GitHub
parent 0338d4153a
commit bbd6d0b4e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -270,9 +270,14 @@ fn handle_conn<T>(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 {