From b607d973319490c35739948823a689033a360ebd Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 27 Apr 2023 17:32:58 +0200 Subject: [PATCH] Make mod_muc_log_http redirect to page that end with / (processone/ejabberd#3177) Code copied from ejabberd_web_admin.erl, commit 5ec21438 --- mod_muc_log_http/src/mod_muc_log_http.erl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mod_muc_log_http/src/mod_muc_log_http.erl b/mod_muc_log_http/src/mod_muc_log_http.erl index ed4c6e8..9a79f31 100644 --- a/mod_muc_log_http/src/mod_muc_log_http.erl +++ b/mod_muc_log_http/src/mod_muc_log_http.erl @@ -32,8 +32,19 @@ %%% REQUEST HANDLERS %%%---------------------------------------------------------------------- -process(LocalPath, Request) -> - serve(LocalPath, Request). +process(Path, #request{raw_path = RawPath} = Request) -> + Continue = case Path of + [E] -> + binary:match(E, <<".">>) /= nomatch; + _ -> + false + end, + case Continue orelse binary:at(RawPath, size(RawPath) - 1) == $/ of + true -> + serve(Path, Request); + _ -> + {301, [{<<"Location">>, <>}], <<>>} + end. serve(LocalPathBin, #request{host = Host} = Request) -> DocRoot = binary_to_list(gen_mod:get_module_opt(Host, mod_muc_log, outdir)),