Comparison

util/jid.lua @ 6339:1c19464cde77

util.jid: Use existing join function in jid.prep
author Kim Alvefur <zash@zash.se>
date Thu, 07 Aug 2014 17:35:11 +0200
parent 6338:736c388748fd
child 6340:7e820979fd9b
comparison
equal deleted inserted replaced
6338:736c388748fd 6339:1c19464cde77
63 return node, host, resource; 63 return node, host, resource;
64 end 64 end
65 end 65 end
66 prepped_split = _prepped_split; 66 prepped_split = _prepped_split;
67 67
68 function prep(jid) 68 local function _join(node, host, resource)
69 local node, host, resource = _prepped_split(jid); 69 if not host then return end
70 if host then
71 if node then
72 host = node .. "@" .. host;
73 end
74 if resource then
75 host = host .. "/" .. resource;
76 end
77 end
78 return host;
79 end
80
81 function join(node, host, resource)
82 if not host then return end -- Invalid JID
83 if node and resource then 70 if node and resource then
84 return node.."@"..host.."/"..resource; 71 return node.."@"..host.."/"..resource;
85 elseif node then 72 elseif node then
86 return node.."@"..host; 73 return node.."@"..host;
87 elseif resource then 74 elseif resource then
88 return host.."/"..resource; 75 return host.."/"..resource;
89 end 76 end
90 return host; 77 return host;
78 end
79 join = _join;
80
81 function prep(jid)
82 local node, host, resource = _prepped_split(jid);
83 return _join(node, host, resource);
91 end 84 end
92 85
93 function compare(jid, acl) 86 function compare(jid, acl)
94 -- compare jid to single acl rule 87 -- compare jid to single acl rule
95 -- TODO compare to table of rules? 88 -- TODO compare to table of rules?