Software /
code /
prosody
Comparison
util/http.lua @ 9504:cfbea3064aa9
mod_http: Move normalize_path to util.http
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 14 Oct 2018 14:31:59 +0200 |
parent | 5471:34bfd26525f5 |
child | 9759:1af5106a2c34 |
comparison
equal
deleted
inserted
replaced
9503:3456496d5218 | 9504:cfbea3064aa9 |
---|---|
55 local function contains_token(field, token) | 55 local function contains_token(field, token) |
56 field = ","..field:gsub("[ \t]", ""):lower()..","; | 56 field = ","..field:gsub("[ \t]", ""):lower()..","; |
57 return field:find(","..token:lower()..",", 1, true) ~= nil; | 57 return field:find(","..token:lower()..",", 1, true) ~= nil; |
58 end | 58 end |
59 | 59 |
60 local function normalize_path(path, is_dir) | |
61 if is_dir then | |
62 if path:sub(-1,-1) ~= "/" then path = path.."/"; end | |
63 else | |
64 if path:sub(-1,-1) == "/" then path = path:sub(1, -2); end | |
65 end | |
66 if path:sub(1,1) ~= "/" then path = "/"..path; end | |
67 return path; | |
68 end | |
69 | |
60 return { | 70 return { |
61 urlencode = urlencode, urldecode = urldecode; | 71 urlencode = urlencode, urldecode = urldecode; |
62 formencode = formencode, formdecode = formdecode; | 72 formencode = formencode, formdecode = formdecode; |
63 contains_token = contains_token; | 73 contains_token = contains_token; |
74 normalize_path = normalize_path; | |
64 }; | 75 }; |