Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
7294:5f4d0753c818 | 7296:1859e07ae082 |
---|---|
91 return true | 91 return true |
92 end | 92 end |
93 return false | 93 return false |
94 end | 94 end |
95 | 95 |
96 local function node(jid) | |
97 return (select(1, split(jid))); | |
98 end | |
99 | |
100 local function host(jid) | |
101 return (select(2, split(jid))); | |
102 end | |
103 | |
104 local function resource(jid) | |
105 return (select(3, split(jid))); | |
106 end | |
107 | |
96 local function escape(s) return s and (s:gsub(".", escapes)); end | 108 local function escape(s) return s and (s:gsub(".", escapes)); end |
97 local function unescape(s) return s and (s:gsub("\\%x%x", unescapes)); end | 109 local function unescape(s) return s and (s:gsub("\\%x%x", unescapes)); end |
98 | 110 |
99 return { | 111 return { |
100 split = split; | 112 split = split; |
101 bare = bare; | 113 bare = bare; |
102 prepped_split = prepped_split; | 114 prepped_split = prepped_split; |
103 join = join; | 115 join = join; |
104 prep = prep; | 116 prep = prep; |
105 compare = compare; | 117 compare = compare; |
118 node = node; | |
119 host = host; | |
120 resource = resource; | |
106 escape = escape; | 121 escape = escape; |
107 unescape = unescape; | 122 unescape = unescape; |
108 }; | 123 }; |