util.jid: Add join(node, host, resource) function to join the components and return nil if invalid

Fri, 27 Nov 2009 17:33:55 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 27 Nov 2009 17:33:55 +0000
changeset 2245
df9e18f5c808
parent 2244
730038d3e9e3
child 2246
eb047fe305aa

util.jid: Add join(node, host, resource) function to join the components and return nil if invalid

util/jid.lua file | annotate | diff | comparison | revisions
--- a/util/jid.lua	Fri Nov 27 16:51:05 2009 +0000
+++ b/util/jid.lua	Fri Nov 27 17:33:55 2009 +0000
@@ -65,4 +65,17 @@
 	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;

mercurial