Software /
code /
prosody
File
util/jid.lua @ 367:cc26368294a3
Remove some declarations I added while debugging
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 21 Nov 2008 05:06:01 +0000 |
parent | 366:5691edc7dd63 |
child | 368:34e88709b1b5 |
line wrap: on
line source
local match = string.match; module "jid" function split(jid) if not jid then return; end -- TODO verify JID, and return; if invalid local node, nodelen = match(jid, "^([^@]+)@()"); local host, hostlen = match(jid, "^([^@/]+)()", nodelen) if node and not host then return nil, nil, nil; end local resource = match(jid, "^/(.+)$", hostlen); if (not host) or ((not resource) and #jid >= hostlen) then return nil, nil, nil; end return node, host, resource; end function bare(jid) local node, host = split(jid); if node and host then return node.."@"..host; elseif host then return host; end return nil; end return _M;