diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-11-27 17:33:55 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-11-27 17:33:55 +0000 |
commit | d6a193d93e2670cb2ed48db22051b6fc9922c787 (patch) | |
tree | 34e25ca6a7bfaec3b2529db943ba957e3fde9449 | |
parent | 70ab443a15224fb4ca15a9dde4adb5227bcbda1f (diff) | |
download | prosody-d6a193d93e2670cb2ed48db22051b6fc9922c787.tar.gz prosody-d6a193d93e2670cb2ed48db22051b6fc9922c787.zip |
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
-rw-r--r-- | util/jid.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/util/jid.lua b/util/jid.lua index ccc8309c..b43247cc 100644 --- a/util/jid.lua +++ b/util/jid.lua @@ -65,4 +65,17 @@ function prep(jid) return host; end +function join(node, host, resource) + if node and host and resource then + return node.."@"..host.."/"..resource; + elseif node and host then + return node.."@"..host; + elseif host and resource then + return host.."/"..resource; + elseif host then + return host; + end + return nil; -- Invalid JID +end + return _M; |