0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Fix directory_h.erl back ( ../ ) web links.

This commit is contained in:
ruanpienaar 2018-11-07 23:35:32 +00:00
parent 29043aa7b4
commit 0940e725a0

View file

@ -41,7 +41,13 @@ list_html(Req, {Path, Fs}) ->
"<body>">>, Body, <<"</body></html>\n">>], "<body>">>, Body, <<"</body></html>\n">>],
{HTML, Req, Path}. {HTML, Req, Path}.
links(<<>>, "..") ->
["<a href='/", "..", "'>", "..", "</a><br>\n"];
links(Prefix, "..") ->
Toks = string:tokens(binary_to_list(Prefix), "/"),
Back = lists:join( "/", lists:delete(lists:last(Toks), Toks)),
["<a href='/", "..", $/ ] ++ Back ++ [ "'>", "..", "</a><br>\n"];
links(<<>>, File) -> links(<<>>, File) ->
["<a href='/", File, "'>", File, "</a><br>\n"]; ["<a href='/", File, "'>", File, "</a><br>\n"];
links(Prefix, File) -> links(Prefix, File) ->
["<a href='/", Prefix, $/, File, "'>", File, "</a><br>\n"]. ["<a href='/", Prefix, File, "'>", File, "</a><br>\n"].