Mercurial > prosody-modules
changeset 3432:61368aec97d6
mod_atom: Apply nodeprep via redirect for cache-friendlyness
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 06 Jan 2019 10:24:32 +0100 (2019-01-06) |
parents | 8357cabc31f6 |
children | 213679266dcb |
files | mod_atom/mod_atom.lua |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_atom/mod_atom.lua Sat Jan 05 18:44:50 2019 +0100 +++ b/mod_atom/mod_atom.lua Sun Jan 06 10:24:32 2019 +0100 @@ -6,6 +6,7 @@ local um = require "core.usermanager"; local nodeprep = require "util.encodings".stringprep.nodeprep; local st = require "util.stanza"; +local urlencode = require "util.http".urlencode; module:depends("http") module:provides("http", { @@ -14,8 +15,12 @@ local request, response = event.request, event.response; local actor = request.ip; - user = nodeprep(user); - if not user then return 400; end + local prepped = nodeprep(user); + if not prepped then return 400; end + if prepped ~= user then + response.headers.location = module:http_url() .. "/" .. urlencode(prepped); + return 302; + end if not um.user_exists(user, module.host) then return 404; end