aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMickael Remond <mremond@process-one.net>2015-08-04 09:48:59 +0200
committerMickael Remond <mremond@process-one.net>2015-08-04 09:48:59 +0200
commite3b7d43b76ecbca7c56f2e85c83fa6eaf5de6538 (patch)
tree6fe9474c1ed666099240a0c996f95590387a925d /src
parentDo not crash SIP authentication on SCRAMed passwords (diff)
Add split_jid/1
This is a convenience reverse of make_jid/1. It allows extracting the jid parts without relying on using the jid record structure, to abstract details.
Diffstat (limited to 'src')
-rw-r--r--src/jlib.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/jlib.erl b/src/jlib.erl
index 389783b24..cc0f826ab 100644
--- a/src/jlib.erl
+++ b/src/jlib.erl
@@ -39,7 +39,7 @@
make_error_reply/2, make_error_element/2,
make_correct_from_to_attrs/3, replace_from_to_attrs/3,
replace_from_to/3, replace_from_attrs/2, replace_from/2,
- remove_attr/2, make_jid/3, make_jid/1, string_to_jid/1,
+ remove_attr/2, make_jid/3, make_jid/1, split_jid/1, string_to_jid/1,
jid_to_string/1, is_nodename/1, tolower/1, nodeprep/1,
nameprep/1, resourceprep/1, jid_tolower/1,
jid_remove_resource/1, jid_replace_resource/2,
@@ -214,6 +214,13 @@ make_jid(User, Server, Resource) ->
make_jid({User, Server, Resource}) ->
make_jid(User, Server, Resource).
+%% This is the reverse of make_jid/1
+-spec split_jid(jid()) -> {binary(), binary(), binary()} | error.
+split_jid(#jid{user = U, server = S, resource = R}) ->
+ {U, S, R};
+split_jid(_) ->
+ error.
+
-spec string_to_jid(binary()) -> jid() | error.
string_to_jid(S) ->