# HG changeset patch # User Kim Alvefur # Date 1546766672 -3600 # Node ID 61368aec97d6f1271ad61804b604908f54026d95 # Parent 8357cabc31f69489475bf6839fc1a320c8cdd397 mod_atom: Apply nodeprep via redirect for cache-friendlyness diff -r 8357cabc31f6 -r 61368aec97d6 mod_atom/mod_atom.lua --- 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