Working presence, presence probes and other fixes
[prosody.git] / util / jid.lua
index 9d01e2afa4966f2b2676fda15415f06b678b268d..b1e4131d067c7d6ee353d76179e4527a095e4e80 100644 (file)
@@ -4,5 +4,12 @@ local match = string.match;
 module "jid"
 
 function split(jid)
-       return match(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
+
+return _M;
\ No newline at end of file