aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-14 14:31:59 +0200
committerKim Alvefur <zash@zash.se>2018-10-14 14:31:59 +0200
commit0247a0e9049be42a0420a991feb9b9e9c7800bc0 (patch)
tree34780f34fa2362994aec9153e0ed7db7c1feda7b /util
parent29c9d1f50885e0c6aab08b7ddf4fe1eda08c05cc (diff)
downloadprosody-0247a0e9049be42a0420a991feb9b9e9c7800bc0.tar.gz
prosody-0247a0e9049be42a0420a991feb9b9e9c7800bc0.zip
mod_http: Move normalize_path to util.http
Diffstat (limited to 'util')
-rw-r--r--util/http.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/http.lua b/util/http.lua
index f7259920..cfb89193 100644
--- a/util/http.lua
+++ b/util/http.lua
@@ -57,8 +57,19 @@ local function contains_token(field, token)
return field:find(","..token:lower()..",", 1, true) ~= nil;
end
+local function normalize_path(path, is_dir)
+ if is_dir then
+ if path:sub(-1,-1) ~= "/" then path = path.."/"; end
+ else
+ if path:sub(-1,-1) == "/" then path = path:sub(1, -2); end
+ end
+ if path:sub(1,1) ~= "/" then path = "/"..path; end
+ return path;
+end
+
return {
urlencode = urlencode, urldecode = urldecode;
formencode = formencode, formdecode = formdecode;
contains_token = contains_token;
+ normalize_path = normalize_path;
};