mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Make mod_register_web redirect to page that end with / (#3177)
Code copied from ejabberd_web_admin.erl, commit 5ec21438
This commit is contained in:
parent
d299b97261
commit
0d3f8c7b9f
@ -62,12 +62,26 @@ depends(_Host, _Opts) ->
|
|||||||
%%% HTTP handlers
|
%%% HTTP handlers
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
process([], #request{method = 'GET', lang = Lang}) ->
|
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 ->
|
||||||
|
process2(Path, Request);
|
||||||
|
_ ->
|
||||||
|
{301, [{<<"Location">>, <<RawPath/binary, "/">>}], <<>>}
|
||||||
|
end.
|
||||||
|
|
||||||
|
process2([], #request{method = 'GET', lang = Lang}) ->
|
||||||
index_page(Lang);
|
index_page(Lang);
|
||||||
process([<<"register.css">>],
|
process2([<<"register.css">>],
|
||||||
#request{method = 'GET'}) ->
|
#request{method = 'GET'}) ->
|
||||||
serve_css();
|
serve_css();
|
||||||
process([Section],
|
process2([Section],
|
||||||
#request{method = 'GET', lang = Lang, host = Host,
|
#request{method = 'GET', lang = Lang, host = Host,
|
||||||
ip = {Addr, _Port}}) ->
|
ip = {Addr, _Port}}) ->
|
||||||
Host2 = case ejabberd_router:is_my_host(Host) of
|
Host2 = case ejabberd_router:is_my_host(Host) of
|
||||||
@ -82,7 +96,7 @@ process([Section],
|
|||||||
<<"change_password">> -> form_changepass_get(Host2, Lang);
|
<<"change_password">> -> form_changepass_get(Host2, Lang);
|
||||||
_ -> {404, [], "Not Found"}
|
_ -> {404, [], "Not Found"}
|
||||||
end;
|
end;
|
||||||
process([<<"new">>],
|
process2([<<"new">>],
|
||||||
#request{method = 'POST', q = Q, ip = {Ip, _Port},
|
#request{method = 'POST', q = Q, ip = {Ip, _Port},
|
||||||
lang = Lang, host = _HTTPHost}) ->
|
lang = Lang, host = _HTTPHost}) ->
|
||||||
case form_new_post(Q, Ip) of
|
case form_new_post(Q, Ip) of
|
||||||
@ -97,7 +111,7 @@ process([<<"new">>],
|
|||||||
translate:translate(Lang, get_error_text(Error))]),
|
translate:translate(Lang, get_error_text(Error))]),
|
||||||
{404, [], ErrorText}
|
{404, [], ErrorText}
|
||||||
end;
|
end;
|
||||||
process([<<"delete">>],
|
process2([<<"delete">>],
|
||||||
#request{method = 'POST', q = Q, lang = Lang,
|
#request{method = 'POST', q = Q, lang = Lang,
|
||||||
host = _HTTPHost}) ->
|
host = _HTTPHost}) ->
|
||||||
case form_del_post(Q) of
|
case form_del_post(Q) of
|
||||||
@ -112,7 +126,7 @@ process([<<"delete">>],
|
|||||||
end;
|
end;
|
||||||
%% TODO: Currently only the first vhost is usable. The web request record
|
%% TODO: Currently only the first vhost is usable. The web request record
|
||||||
%% should include the host where the POST was sent.
|
%% should include the host where the POST was sent.
|
||||||
process([<<"change_password">>],
|
process2([<<"change_password">>],
|
||||||
#request{method = 'POST', q = Q, lang = Lang,
|
#request{method = 'POST', q = Q, lang = Lang,
|
||||||
host = _HTTPHost}) ->
|
host = _HTTPHost}) ->
|
||||||
case form_changepass_post(Q) of
|
case form_changepass_post(Q) of
|
||||||
@ -126,7 +140,7 @@ process([<<"change_password">>],
|
|||||||
{404, [], ErrorText}
|
{404, [], ErrorText}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
process(_Path, _Request) ->
|
process2(_Path, _Request) ->
|
||||||
{404, [], "Not Found"}.
|
{404, [], "Not Found"}.
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user