From d6a193d93e2670cb2ed48db22051b6fc9922c787 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Nov 2009 17:33:55 +0000 Subject: util.jid: Add join(node, host, resource) function to join the components and return nil if invalid --- util/jid.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; -- cgit v1.2.3