2 local match = string.match;
3 local tostring = tostring;
8 if not jid then return; end
9 -- TODO verify JID, and return; if invalid
10 local node, nodelen = match(jid, "^([^@]+)@()");
11 local host, hostlen = match(jid, "^([^@/]+)()", nodelen)
12 if node and not host then return nil, nil, nil; end
13 local resource = match(jid, "^/(.+)$", hostlen);
14 if (not host) or ((not resource) and #jid >= hostlen) then return nil, nil, nil; end
15 return node, host, resource;
19 local node, host = split(jid);
21 return node.."@"..host;