Comparison

util/jid.lua @ 29:b847875801e5

jid.split(): Return nil when passed nil
author Matthew Wild <mwild1@gmail.com>
date Tue, 30 Sep 2008 19:49:36 +0100
parent 27:859b316e2fb0
child 104:cfbd3b849f9e
comparison
equal deleted inserted replaced
28:4a238233f278 29:b847875801e5
2 local match = string.match; 2 local match = string.match;
3 3
4 module "jid" 4 module "jid"
5 5
6 function split(jid) 6 function split(jid)
7 if not jid then return nil; end
7 local node = match(jid, "^([^@]+)@"); 8 local node = match(jid, "^([^@]+)@");
8 local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)"); 9 local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)");
9 local resource = match(jid, "/(.+)$"); 10 local resource = match(jid, "/(.+)$");
10 return node, server, resource; 11 return node, server, resource;
11 end 12 end