Changeset

4869:1fac86aab90b

Merge with Zash
author Matthew Wild <mwild1@gmail.com>
date Sat, 12 May 2012 03:36:15 +0100
parents 4867:b4219d987d05 (current diff) 4868:550f0a5e85c5 (diff)
children 4870:ca39f9b4cc8e
files
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_files.lua	Sat May 12 03:24:06 2012 +0100
+++ b/plugins/mod_http_files.lua	Sat May 12 03:36:15 2012 +0100
@@ -27,11 +27,18 @@
 
 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
-		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
+		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");