mirror of https://github.com/bjc/prosody
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
560 B
24 lines
560 B
|
|
local match = string.match;
|
|
|
|
module "jid"
|
|
|
|
function split(jid)
|
|
if not jid then return; end
|
|
local node, nodepos = match(jid, "^([^@]+)@()");
|
|
local host, hostpos = match(jid, "^([^@/]+)()", nodepos)
|
|
if node and not host then return nil, nil, nil; end
|
|
local resource = match(jid, "^/(.+)$", hostpos);
|
|
if (not host) or ((not resource) and #jid >= hostpos) then return nil, nil, nil; end
|
|
return node, host, resource;
|
|
end
|
|
|
|
function bare(jid)
|
|
local node, host = split(jid);
|
|
if node and host then
|
|
return node.."@"..host;
|
|
end
|
|
return host;
|
|
end
|
|
|
|
return _M;
|
|
|