mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
This commit is contained in:
parent
4633eb56fb
commit
1c3c5302ba
2 changed files with 85 additions and 0 deletions
15
util/jid.lua
15
util/jid.lua
|
@ -93,6 +93,18 @@ local function compare(jid, acl)
|
|||
return false
|
||||
end
|
||||
|
||||
local function node(jid)
|
||||
return (select(1, split(jid)));
|
||||
end
|
||||
|
||||
local function host(jid)
|
||||
return (select(2, split(jid)));
|
||||
end
|
||||
|
||||
local function resource(jid)
|
||||
return (select(3, split(jid)));
|
||||
end
|
||||
|
||||
local function escape(s) return s and (s:gsub(".", escapes)); end
|
||||
local function unescape(s) return s and (s:gsub("\\%x%x", unescapes)); end
|
||||
|
||||
|
@ -103,6 +115,9 @@ return {
|
|||
join = join;
|
||||
prep = prep;
|
||||
compare = compare;
|
||||
node = node;
|
||||
host = host;
|
||||
resource = resource;
|
||||
escape = escape;
|
||||
unescape = unescape;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue