X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fjid.lua;h=27afab3e275e2de573e8b18f6211a7fbebfb5476;hb=95dfe4b0aaaf26ee4651c09eb9757c56210a135a;hp=08e633359e6afafeeb8d8144d1df8c991ed265a2;hpb=fcbcf2bab2c66ab3045d5de6d21ee56b164acb92;p=prosody.git diff --git a/util/jid.lua b/util/jid.lua index 08e63335..27afab3e 100644 --- a/util/jid.lua +++ b/util/jid.lua @@ -37,11 +37,7 @@ end split = _split; function bare(jid) - local node, host = _split(jid); - if node and host then - return node.."@"..host; - end - return host; + return jid and match(jid, "^[^/]+"); end local function _prepped_split(jid) @@ -65,30 +61,22 @@ local function _prepped_split(jid) end prepped_split = _prepped_split; -function prep(jid) - local node, host, resource = _prepped_split(jid); - if host then - if node then - host = node .. "@" .. host; - end - if resource then - host = host .. "/" .. resource; - end - end - return host; -end - -function join(node, host, resource) - if node and host and resource then +local function _join(node, host, resource) + if not host then return end + if node and resource then return node.."@"..host.."/"..resource; - elseif node and host then + elseif node then return node.."@"..host; - elseif host and resource then + elseif resource then return host.."/"..resource; - elseif host then - return host; end - return nil; -- Invalid JID + return host; +end +join = _join; + +function prep(jid) + local node, host, resource = _prepped_split(jid); + return _join(node, host, resource); end function compare(jid, acl)