util/jid.lua

Fri, 24 Oct 2008 07:27:36 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 24 Oct 2008 07:27:36 +0100
branch
s2s
changeset 148
4c0dcd245d34
parent 109
7efedc96352a
child 365
a59300fc22ec
permissions
-rw-r--r--

s2s works! \o/ \o/


local match = string.match;

module "jid"

function split(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;

mercurial