mod_muc_webchat_url: Fix default url
[prosody-modules.git] / mod_jid_prep / mod_jid_prep.lua
blob8db9b6bf3cae9a3f2af931a0a5d750cf71ea201a
1 -- Run JIDs through stringprep processing on behalf of clients
2 -- http://xmpp.org/extensions/inbox/jidprep.html
4 local jid_prep = require "util.jid".prep;
5 local st = require "util.stanza";
7 local xmlns_prep = "urn:xmpp:jidprep:0";
9 module:add_feature(xmlns_prep);
11 function prep_jid(event)
12 local stanza = event.stanza;
13 local jid = jid_prep(stanza:get_child_text("jid", xmlns_prep));
14 if not jid then
15 return event.origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
16 end
17 return event.origin.send(st.reply(stanza):tag("jid", { xmlns = xmlns_prep }):text(jid));
18 end
21 module:hook("iq/host/"..xmlns_prep..":jid", prep_jid);
23 module:depends("http");
24 module:provides("http", {
25 route = {
26 ["GET /*"] = function (event, jid)
27 return jid_prep(jid) or 400;
28 end;
30 });