diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-11-29 07:15:04 +0500 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-11-29 07:15:04 +0500 |
commit | d7b707744de72882f42d0b688f9ecfd7f9fe3f12 (patch) | |
tree | 946f436f1268fd970de15a3d8ef7d11a38fff245 /plugins/mod_http.lua | |
parent | bfd3085f782460b3f45f99c48961e974858d2237 (diff) | |
download | prosody-d7b707744de72882f42d0b688f9ecfd7f9fe3f12.tar.gz prosody-d7b707744de72882f42d0b688f9ecfd7f9fe3f12.zip |
mod_http: Fix pattern and slightly improve efficiency and memory usage of wildcard HTTP handlers
Diffstat (limited to 'plugins/mod_http.lua')
-rw-r--r-- | plugins/mod_http.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index f386f870..e73778ae 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -88,10 +88,10 @@ function module.add_host(module) local data = handler; handler = function () return data; end elseif event_name:sub(-2, -1) == "/*" then - local base_path = event_name:match("/(.+)/*$"); + local base_path_len = #event_name:match("(/.+/)%*$")+1; local _handler = handler; handler = function (event) - local path = event.request.path:sub(#base_path+1); + local path = event.request.path:sub(base_path_len); return _handler(event, path); end; end |