util/jid.lua
changeset 3480 97831dfe7f72
parent 3375 29e51e1c7c3d
child 4407 f78c6f5fa090
equal deleted inserted replaced
3479:f68198c2f68f 3480:97831dfe7f72
    15 
    15 
    16 module "jid"
    16 module "jid"
    17 
    17 
    18 local function _split(jid)
    18 local function _split(jid)
    19 	if not jid then return; end
    19 	if not jid then return; end
    20 	local node, nodepos = match(jid, "^([^@]+)@()");
    20 	local node, nodepos = match(jid, "^([^@/]+)@()");
    21 	local host, hostpos = match(jid, "^([^@/]+)()", nodepos)
    21 	local host, hostpos = match(jid, "^([^@/]+)()", nodepos)
    22 	if node and not host then return nil, nil, nil; end
    22 	if node and not host then return nil, nil, nil; end
    23 	local resource = match(jid, "^/(.+)$", hostpos);
    23 	local resource = match(jid, "^/(.+)$", hostpos);
    24 	if (not host) or ((not resource) and #jid >= hostpos) then return nil, nil, nil; end
    24 	if (not host) or ((not resource) and #jid >= hostpos) then return nil, nil, nil; end
    25 	return node, host, resource;
    25 	return node, host, resource;