Software /
code /
prosody
Comparison
util/jid.lua @ 6342:379faad8ce9f
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 09 Aug 2014 21:48:52 +0200 |
parent | 6340:7e820979fd9b |
child | 6777:5de6b93d0190 |
comparison
equal
deleted
inserted
replaced
6336:11510d4d3b57 | 6342:379faad8ce9f |
---|---|
35 return node, host, resource; | 35 return node, host, resource; |
36 end | 36 end |
37 split = _split; | 37 split = _split; |
38 | 38 |
39 function bare(jid) | 39 function bare(jid) |
40 local node, host = _split(jid); | 40 return jid and match(jid, "^[^/]+"); |
41 if node and host then | |
42 return node.."@"..host; | |
43 end | |
44 return host; | |
45 end | 41 end |
46 | 42 |
47 local function _prepped_split(jid) | 43 local function _prepped_split(jid) |
48 local node, host, resource = _split(jid); | 44 local node, host, resource = _split(jid); |
49 if host then | 45 if host then |
63 return node, host, resource; | 59 return node, host, resource; |
64 end | 60 end |
65 end | 61 end |
66 prepped_split = _prepped_split; | 62 prepped_split = _prepped_split; |
67 | 63 |
68 function prep(jid) | 64 local function _join(node, host, resource) |
69 local node, host, resource = _prepped_split(jid); | 65 if not host then return end |
70 if host then | 66 if node and resource then |
71 if node then | 67 return node.."@"..host.."/"..resource; |
72 host = node .. "@" .. host; | 68 elseif node then |
73 end | 69 return node.."@"..host; |
74 if resource then | 70 elseif resource then |
75 host = host .. "/" .. resource; | 71 return host.."/"..resource; |
76 end | |
77 end | 72 end |
78 return host; | 73 return host; |
79 end | 74 end |
75 join = _join; | |
80 | 76 |
81 function join(node, host, resource) | 77 function prep(jid) |
82 if node and host and resource then | 78 local node, host, resource = _prepped_split(jid); |
83 return node.."@"..host.."/"..resource; | 79 return _join(node, host, resource); |
84 elseif node and host then | |
85 return node.."@"..host; | |
86 elseif host and resource then | |
87 return host.."/"..resource; | |
88 elseif host then | |
89 return host; | |
90 end | |
91 return nil; -- Invalid JID | |
92 end | 80 end |
93 | 81 |
94 function compare(jid, acl) | 82 function compare(jid, acl) |
95 -- compare jid to single acl rule | 83 -- compare jid to single acl rule |
96 -- TODO compare to table of rules? | 84 -- TODO compare to table of rules? |