Annotate

util/jid.lua @ 104:cfbd3b849f9e

Fixed: util/jid.lua now returns module object
author Waqas Hussain <waqas20@gmail.com>
date Tue, 14 Oct 2008 09:54:49 +0500
parent 29:b847875801e5
child 109:7efedc96352a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
1
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
2 local match = string.match;
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
3
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
4 module "jid"
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
5
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
6 function split(jid)
29
b847875801e5 jid.split(): Return nil when passed nil
Matthew Wild <mwild1@gmail.com>
parents: 27
diff changeset
7 if not jid then return nil; end
27
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
8 local node = match(jid, "^([^@]+)@");
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
9 local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)");
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
10 local resource = match(jid, "/(.+)$");
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
11 return node, server, resource;
0
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
12 end
104
cfbd3b849f9e Fixed: util/jid.lua now returns module object
Waqas Hussain <waqas20@gmail.com>
parents: 29
diff changeset
13
cfbd3b849f9e Fixed: util/jid.lua now returns module object
Waqas Hussain <waqas20@gmail.com>
parents: 29
diff changeset
14 return _M;