diff options
author | Matthew Wild <mwild1@gmail.com> | 2016-03-17 23:15:08 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2016-03-17 23:15:08 +0000 |
commit | 1c3c5302ba25e5474f5319f2f766a0a9dc31802c (patch) | |
tree | 127efd433ec839250b105b8fc3b907af374620ea /util/jid.lua | |
parent | 4633eb56fbfda4ba0e5d790203282f374c8a8079 (diff) | |
download | prosody-1c3c5302ba25e5474f5319f2f766a0a9dc31802c.tar.gz prosody-1c3c5302ba25e5474f5319f2f766a0a9dc31802c.zip |
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Diffstat (limited to 'util/jid.lua')
-rw-r--r-- | util/jid.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util/jid.lua b/util/jid.lua index 76155ac7..60bb0829 100644 --- a/util/jid.lua +++ b/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; }; |