mod_http: Clean up redirects handlers for wildcard on http module unload
authorKim Alvefur <zash@zash.se>
Wed, 22 Dec 2021 19:27:03 +0100
changeset 12117 86e6f0810956
parent 12116 08a949e63541
child 12118 e32f90c81519
mod_http: Clean up redirects handlers for wildcard on http module unload These would previously be left behind. Probably mostly harmless except for clogging up the `debug:events()` listing in the console.
plugins/mod_http.lua
--- a/plugins/mod_http.lua	Wed Dec 22 18:47:45 2021 +0100
+++ b/plugins/mod_http.lua	Wed Dec 22 19:27:03 2021 +0100
@@ -227,6 +227,13 @@
 		for event_name, handlers in pairs(app_handlers) do
 			module:unhook_object_event(server, event_name, handlers.main);
 			module:unhook_object_event(server, event_name, handlers.cors);
+
+			if event_name:sub(-2, -1) == "/*" then
+				module:unhook_object_event(server, event_name:sub(1, -3), redir_handler, -1);
+			elseif event_name:sub(-1, -1) == "/" then
+				module:unhook_object_event(server, event_name:sub(1, -2), redir_handler, -1);
+			end
+
 			local options_event_name = event_name:gsub("^%S+", "OPTIONS");
 			module:unhook_object_event(server, options_event_name, handlers.options);
 		end