mod_http_dir_listing: Fix file ending detection for filenames with more than one period and don't index mime types with nil
authorKim Alvefur <zash@zash.se>
Mon, 01 Jul 2013 23:06:00 +0200
changeset 1099 754c15641369
parent 1098 cbbeac61f1ab
child 1100 aa93cf0b1242
mod_http_dir_listing: Fix file ending detection for filenames with more than one period and don't index mime types with nil
mod_http_dir_listing/http_dir_listing/mod_http_dir_listing.lua
--- a/mod_http_dir_listing/http_dir_listing/mod_http_dir_listing.lua	Sun Jun 30 20:14:28 2013 +0200
+++ b/mod_http_dir_listing/http_dir_listing/mod_http_dir_listing.lua	Mon Jul 01 23:06:00 2013 +0200
@@ -40,8 +40,8 @@
 		if file:sub(1,1) ~= "." then
 			local attr = stat(full_path..file) or {};
 			local path = { file };
-			local file_ext = file:match"%.(.-)$";
-			local type = attr.mode == "file" and mime_map and mime_map[file_ext] or nil;
+			local file_ext = file:match"%.([^.]+)$";
+			local type = attr.mode == "file" and file_ext and mime_map and mime_map[file_ext] or nil;
 			local class = table.concat({ attr.mode or "unknown", file_ext, type and type:match"^[^/]+" }, " ");
 			path.is_directory = attr.mode == "directory";
 			filelist:tag("li", { class = class })