projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mod_vcard: Remove vcard_compatibility COMPAT (moved to mod_compat_vcard in prosody...
[prosody.git]
/
plugins
/
mod_http_files.lua
diff --git
a/plugins/mod_http_files.lua
b/plugins/mod_http_files.lua
index 9be735b79d4ac647ce2095f9538f09515e7a5f99..bdc3a01144959d92cbacac9b112484dca20cd94a 100644
(file)
--- a/
plugins/mod_http_files.lua
+++ b/
plugins/mod_http_files.lua
@@
-27,11
+27,18
@@
local mime_map = {
function serve_file(event, path)
local response = event.response;
function serve_file(event, path)
local response = event.response;
+ local orig_path = event.request.path;
local full_path = http_base.."/"..path;
if stat(full_path, "mode") == "directory" then
local full_path = http_base.."/"..path;
if stat(full_path, "mode") == "directory" then
- if stat(full_path.."/index.html", "mode") == "file" then
- return serve_file(event, path.."/index.html");
+ if full_path:sub(-1) ~= "/" then
+ response.headers.location = orig_path.."/";
+ return 301;
end
end
+ if stat(full_path.."index.html", "mode") == "file" then
+ return serve_file(event, path.."index.html");
+ end
+
+ -- TODO File listing
return 403;
end
local f, err = open(full_path, "rb");
return 403;
end
local f, err = open(full_path, "rb");
@@
-51,7
+58,7
@@
end
module:provides("http", {
route = {
module:provides("http", {
route = {
- ["/*"] = serve_file;
+ ["
GET
/*"] = serve_file;
};
});
};
});