Make mod_muc_log_http redirect to page that end with / (processone/ejabberd#3177)

Code copied from ejabberd_web_admin.erl, commit 5ec21438
This commit is contained in:
Badlop 2023-04-27 17:32:58 +02:00
parent 8a91598b04
commit b607d97331
1 changed files with 13 additions and 2 deletions

View File

@ -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">>, <<RawPath/binary, "/">>}], <<>>}
end.
serve(LocalPathBin, #request{host = Host} = Request) ->
DocRoot = binary_to_list(gen_mod:get_module_opt(Host, mod_muc_log, outdir)),