amalgame/commit
FIXED: serve_static failed when http:prefix is not the empty string. Reported as issue/2 by Joachim Neubert
author | Jacco van Ossenbruggen |
---|---|
Thu Aug 21 17:15:41 2014 +0200 | |
committer | Jacco van Ossenbruggen |
Thu Aug 21 17:16:45 2014 +0200 | |
commit | 8dcefd6ba1057862c208a41801ba450796986573 |
tree | 53b81e7d4ce0147b9cf808e7225a4ca814ec8aed |
parent | 654a93f2a6387e03504ada8dbd6c18a30f596bfc |
Diff style: patch stat
diff --git a/config-available/025-amalgame.pl b/config-available/025-amalgame.pl index e3b3eaf..9a0ac9f 100644 --- a/config-available/025-amalgame.pl +++ b/config-available/025-amalgame.pl @@ -32,8 +32,8 @@ http:location(img, root(img), [ priority(-100) ]). :- rdf_load_library(amalgame). :- rdf_load_library(dc). -/* Now all namespaces should have been defined, -* we can load the amalgame applications: +/* Now all namespaces should have been defined, +* we can load the amalgame applications: */ :- use_module(applications(startpage)). :- use_module(applications(builder)). @@ -51,15 +51,9 @@ user:file_search_path(img, web(img)). serve_files_in_directory(img), [prefix]). serve_static(Alias, Request) :- - memberchk(path(PathInfo), Request), - sub_atom(PathInfo, 1, Len, End, Alias), - ( End < 2 - -> Path='.' - ; debug(foo, '~w', [End]), - Start is Len + 2, - sub_atom(PathInfo, Start, _, 0, Path) - ), - Term =.. [Alias,Path], + memberchk(path_info(PathInfo), Request), + !, + Term =.. [Alias,PathInfo], ( absolute_file_name(Term, _, [file_type(directory), access(read), @@ -68,3 +62,11 @@ serve_static(Alias, Request) :- -> http_reply_dirindex(Term, [unsafe(true)], Request) ; http_reply_file(Term, [], Request) ). + +serve_static(Alias, Request) :- + \+ memberchk(path_info(_), Request), + !, + memberchk(path(Path), Request), + sub_atom(Path, _, _, 1, Alias), + Term =.. [Alias, '.' ], + http_reply_dirindex(Term, [unsafe(true)], Request).