Comparison

plugins/mod_http.lua @ 4911:4c8575b09ff6

mod_http: Fix normalize_path('/') to not return an empty string, fixes module:http_url()
author Kim Alvefur <zash@zash.se>
date Fri, 25 May 2012 03:39:45 +0200
parent 4892:6c8074f47ca4
child 4915:3fbc01d1fc5a
comparison
equal deleted inserted replaced
4910:e5ec60dfb202 4911:4c8575b09ff6
15 local server = require "net.http.server"; 15 local server = require "net.http.server";
16 16
17 server.set_default_host(module:get_option_string("http_default_host")); 17 server.set_default_host(module:get_option_string("http_default_host"));
18 18
19 local function normalize_path(path) 19 local function normalize_path(path)
20 if path:sub(-1,-1) == "/" then path = path:sub(1, -2); end
20 if path:sub(1,1) ~= "/" then path = "/"..path; end 21 if path:sub(1,1) ~= "/" then path = "/"..path; end
21 if path:sub(-1,-1) == "/" then path = path:sub(1, -2); end
22 return path; 22 return path;
23 end 23 end
24 24
25 local function get_http_event(host, app_path, key) 25 local function get_http_event(host, app_path, key)
26 local method, path = key:match("^(%S+)%s+(.+)$"); 26 local method, path = key:match("^(%S+)%s+(.+)$");