# HG changeset patch # User Kim Alvefur # Date 1557737400 -7200 # Node ID 0b670831ace35f6c4da4ecba312490a5341af7d8 # Parent 61a9c087730a2645e61466026f17115b0b1726d8 mod_http_muc_log: Correctly build absolute URLs Handles case of http_path being "/", where :http_url() ends with a slash, so there would be two slashes. diff -r 61a9c087730a -r 0b670831ace3 mod_http_muc_log/mod_http_muc_log.lua --- a/mod_http_muc_log/mod_http_muc_log.lua Mon May 13 00:23:04 2019 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Mon May 13 10:50:00 2019 +0200 @@ -59,6 +59,22 @@ end end +local function get_absolute_link(room, date) + local link = url.parse(module:http_url()); + local path = url.parse_path(link.path); + if room then + table.insert(path, room); + if date then + table.insert(path, date) + path.is_directory = false; + else + path.is_directory = true; + end + end + link.path = url.build_path(path) + return url.build(link) +end + -- Whether room can be joined by anyone local function open_room(room) -- : boolean if type(room) == "string" then @@ -84,7 +100,7 @@ local room = event.room; if open_room(room) then table.insert(event.form, { name = "muc#roominfo_logs", type="text-single" }); - event.formdata["muc#roominfo_logs"] = module:http_url() .. "/" .. get_link(jid_split(event.room.jid), nil); + event.formdata["muc#roominfo_logs"] = get_absolute_link(jid_split(event.room.jid), nil); end end);