webmcp
diff framework/env/request/default_router.lua @ 250:db79324a13fe
Work on static file delivery
author | jbe |
---|---|
date | Sun Mar 01 21:38:07 2015 +0100 (2015-03-01) |
parents | 4ab91adeab6f |
children | 169dfbd0246a |
line diff
1.1 --- a/framework/env/request/default_router.lua Sun Mar 01 21:20:29 2015 +0100 1.2 +++ b/framework/env/request/default_router.lua Sun Mar 01 21:38:07 2015 +0100 1.3 @@ -12,10 +12,26 @@ 1.4 if not path then 1.5 return nil 1.6 end 1.7 - local module, action, view, id, suffix 1.8 if path == "" then 1.9 return {module = "index", view = "index"} 1.10 end 1.11 + local static = string.match(path, "^static/([-./0-9A-Z_a-z]+)$") 1.12 + if static then 1.13 + if 1.14 + string.match(static, "^/") or 1.15 + string.match(static, "//") or 1.16 + string.match(static, "/$") or 1.17 + string.match(static, "^%.%.?$") or 1.18 + string.match(static, "/%.%.?$") or 1.19 + string.match(static, "^%.%.?/") or 1.20 + string.match(static, "/%.%.?/") -- TODO: improve 1.21 + then 1.22 + return nil 1.23 + else 1.24 + return {static = static} 1.25 + end 1.26 + end 1.27 + local module, action, view, id, suffix 1.28 module = string.match(path, "^([^/]+)/$") 1.29 if module then 1.30 return {module = module, view = "index"}