Diff

plugins/mod_http.lua @ 12113:86e6f0810956

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.
author Kim Alvefur <zash@zash.se>
date Wed, 22 Dec 2021 19:27:03 +0100
parent 11727:f3aee8a825cc
child 12187:94253e02d47d
line wrap: on
line diff
--- 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