diff --git a/TODO b/TODO
index cbb5960..f040a1f 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,4 @@
+ * write overview documentation
* html escpae file names
* url quote file name in ahref
* range (partial)
diff --git a/src/crary_dir_listing.erl b/src/crary_dir_listing.erl
index 1b2436e..3de3ef8 100644
--- a/src/crary_dir_listing.erl
+++ b/src/crary_dir_listing.erl
@@ -31,7 +31,7 @@
-module(crary_dir_listing).
--export([handler/2]).
+-export([handler/3]).
%% methods other handler modules may find useful
-export([file_path/2]).
@@ -52,8 +52,8 @@
%% @doc Handle the request as any good dir lister would.
%% @spec handler(crary:crary_req(), string()) -> void()
-handler(#crary_req{method = "GET"} = Req, BaseDir) ->
- case file_path(Req, BaseDir) of
+handler(#crary_req{method = "GET"} = Req, UriPath, BaseDir) ->
+ case file_path(BaseDir, UriPath) of
Path ->
case file:read_file_info(Path) of
{ok, #file_info{type = directory}} ->
@@ -68,7 +68,7 @@ handler(#crary_req{method = "GET"} = Req, BaseDir) ->
crary:forbidden(Req)
end
end;
-handler(Req, _BaseDir) ->
+handler(Req, _UriPath, _BaseDir) ->
crary:not_implemented(Req).
dir_listing(Req, Path) ->
@@ -217,18 +217,14 @@ has_index_file([Name | Names], Path) ->
%% @doc Create a file path by appending the Uri to Base (making sure
%% that Uri doesn't try to escape from Base by using `..' or such)
-%% @spec file_path(crary:crary_req(), string()) -> string()
+%% @spec file_path(string(), SubDir) -> string()
+%% SubDir = crary:crary_req() | uri:uri() | string()
%% @throws not_found
-file_path(#crary_req{uri = Uri}, Base) ->
- file_path(Uri, Base);
-file_path(#uri{path = UriPath, frag = ""}, Base) ->
- file_path_(UriPath, Base);
-file_path(#uri{}, _Base) ->
- throw(bad_request);
-file_path(Uri, Base) when is_list(Uri) ->
- file_path(uri:from_string(Uri), Base).
-
-file_path_(UriPath, Base)->
+file_path(Base, #crary_req{uri = Uri}) ->
+ file_path(Base, Uri);
+file_path(Base, #uri{path = UriPath}) ->
+ file_path(Base, UriPath);
+file_path(Base, UriPath) ->
Parts = lists:foldl(
fun (Part, Acc) ->
case Part of
--
1.5.3.7