blob: c9ea5b736f7a3b3a445c13141bbad4446d209625 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
local match = string.match;
module "jid"
function split(jid)
if not jid then return; end
-- TODO verify JID, and return; if invalid
local node = match(jid, "^([^@]+)@");
local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)");
local resource = match(jid, "/(.+)$");
return node, server, resource;
end
function bare(jid)
local node, host = split(jid);
return node.."@"..host;
end
return _M;
|