Changeset

2820:0ad29a5485d6

util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
author Matthew Wild <mwild1@gmail.com>
date Fri, 27 Nov 2009 17:33:55 +0000
parents 2819:49e9a8d57981
children 2821:c0981e104abc
files util/jid.lua
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/jid.lua	Wed Nov 25 22:00:33 2009 +0500
+++ 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;