Software /
code /
prosody
Diff
util/jid.lua @ 7296:1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 17 Mar 2016 23:15:08 +0000 |
parent | 6891:7f76c77ddcb8 |
child | 7321:a7199fc8a50e |
line wrap: on
line diff
--- a/util/jid.lua Fri Mar 18 00:08:33 2016 +0100 +++ b/util/jid.lua Thu Mar 17 23:15:08 2016 +0000 @@ -93,6 +93,18 @@ 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 @@ join = join; prep = prep; compare = compare; + node = node; + host = host; + resource = resource; escape = escape; unescape = unescape; };