net.http.files: Validate argument to setup function 0.12
authorKim Alvefur <zash@zash.se>
Tue, 27 Feb 2024 17:14:16 +0100
branch0.12
changeset 13449 360e05f33835
parent 13412 d7857ef7843a
child 13450 dba7073f1452
child 13469 54a936345aaa
net.http.files: Validate argument to setup function Fixes error in #1765 by throwing an error earlier
net/http/files.lua
--- a/net/http/files.lua	Sun Dec 17 18:55:14 2023 +0100
+++ b/net/http/files.lua	Tue Feb 27 17:14:16 2024 +0100
@@ -58,7 +58,7 @@
 	local cache = new_cache(opts.cache_size or 256);
 	local cache_max_file_size = tonumber(opts.cache_max_file_size) or 1024
 	-- luacheck: ignore 431
-	local base_path = opts.path;
+	local base_path = assert(opts.path, "invalid argument to net.http.files.path(), missing required 'path'");
 	local dir_indices = opts.index_files or { "index.html", "index.htm" };
 	local directory_index = opts.directory_index;
 	local function serve_file(event, path)