aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMickael Remond <mremond@process-one.net>2016-03-21 09:44:23 +0100
committerMickael Remond <mremond@process-one.net>2016-03-21 09:44:23 +0100
commit31c194a682d41663a66f7d9b42fcc950511de83a (patch)
tree9f7ba0221a269522d91422ed6f19c49f55139e8e /src
parentMerge branch 'master' of github.com:processone/ejabberd (diff)
Add simple Elixir unit test on jid:from_string
Diffstat (limited to 'src')
-rw-r--r--src/jid.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/jid.erl b/src/jid.erl
index cc387ecbe..7bdd652ae 100644
--- a/src/jid.erl
+++ b/src/jid.erl
@@ -87,9 +87,13 @@ split(#jid{user = U, server = S, resource = R}) ->
split(_) ->
error.
--spec from_string(binary()) -> jid() | error.
-
-from_string(S) ->
+-spec from_string([binary()|string()]) -> jid() | error.
+from_string(S) when is_list(S) ->
+ %% We do not accept list because we want to enforce good practice of
+ %% using binaries for string. However, we do not let it crash to avoid
+ %% losing associated ets table.
+ {error, need_jid_as_binary};
+from_string(S) when is_binary(S) ->
SplitPattern = ets:lookup_element(jlib, string_to_jid_pattern, 2),
Size = size(S),
End = Size-1,