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; |