Remove some declarations I added while debugging
[prosody.git] / util / jid.lua
1
2 local match = string.match;
3
4 module "jid"
5
6 function split(jid)
7         if not jid then return; end
8         -- TODO verify JID, and return; if invalid
9         local node, nodelen = match(jid, "^([^@]+)@()");
10         local host, hostlen = match(jid, "^([^@/]+)()", nodelen)
11         if node and not host then return nil, nil, nil; end
12         local resource = match(jid, "^/(.+)$", hostlen);
13         if (not host) or ((not resource) and #jid >= hostlen) then return nil, nil, nil; end
14         return node, host, resource;
15 end
16
17 function bare(jid)
18         local node, host = split(jid);
19         if node and host then
20                 return node.."@"..host;
21         elseif host then
22                 return host;
23         end
24         return nil;
25 end
26
27 return _M;