util/jid.lua
author Matthew Wild <mwild1@gmail.com>
Sat, 27 Sep 2008 19:17:40 +0100
changeset 27 859b316e2fb0
parent 0 3e3171b59028
child 29 b847875801e5
permissions -rw-r--r--
Fixing jid.split() for all JIDs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)
27
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
     7
	local node = match(jid, "^([^@]+)@");
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
     8
	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
     9
	local resource = match(jid, "/(.+)$");
859b316e2fb0 Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
    10
	return node, server, resource;
0
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
    11
end