Fixing jid.split() for all JIDs
authorMatthew Wild <mwild1@gmail.com>
Sat, 27 Sep 2008 18:17:40 +0000 (19:17 +0100)
committerMatthew Wild <mwild1@gmail.com>
Sat, 27 Sep 2008 18:17:40 +0000 (19:17 +0100)
util/jid.lua

index 9d01e2afa4966f2b2676fda15415f06b678b268d..b7116fdfad5ce7983ffa78890cada05d5dcc0e4f 100644 (file)
@@ -4,5 +4,8 @@ local match = string.match;
 module "jid"
 
 function split(jid)
-       return match(jid, "^([^@]+)@([^/]+)/?(.*)$");
+       local node = match(jid, "^([^@]+)@");
+       local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)");
+       local resource = match(jid, "/(.+)$");
+       return node, server, resource;
 end