Mercurial > prosody-modules
changeset 3593:0b670831ace3
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 13 May 2019 10:50:00 +0200 (2019-05-13) |
parents | 61a9c087730a |
children | b66111f75e4b |
files | mod_http_muc_log/mod_http_muc_log.lua |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);