diff options
author | Paul Schoenfelder <paulschoenfelder@gmail.com> | 2016-11-10 18:35:30 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-10 18:35:30 -0600 |
commit | b34b0fbd8caddeba708f5c91f3ae995799aec3f4 (patch) | |
tree | e1fd60439dd5c03d36905001a13db7fa610d3964 | |
parent | Version 1.0.0 (diff) | |
parent | Add support for prefix format: nick!hostname (diff) |
Merge pull request #57 from janza/master
Add support for prefix format: nick!hostname
-rw-r--r-- | lib/exirc/utils.ex | 2 | ||||
-rw-r--r-- | test/utils_test.exs | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/exirc/utils.ex b/lib/exirc/utils.ex index a5f18b5..d3f903c 100644 --- a/lib/exirc/utils.ex +++ b/lib/exirc/utils.ex @@ -25,7 +25,7 @@ defmodule ExIrc.Utils do end end - @prefix_pattern ~r/^(?<nick>[^!]+)(?:(?:!(?<user>[^@ ]+))?(?:@(?<host>[\w.:-]+)))?$/ + @prefix_pattern ~r/^(?<nick>[^!]+)(?:!(?:(?<user>[^@ ]+)@)?(?:(?<host>[\w.:-]+)))?$/ defp parse_from(from, msg) do from_str = IO.iodata_to_binary(from) parts = Regex.run(@prefix_pattern, from_str, capture: :all_but_first) diff --git a/test/utils_test.exs b/test/utils_test.exs index 31dac37..38e343b 100644 --- a/test/utils_test.exs +++ b/test/utils_test.exs @@ -62,6 +62,13 @@ defmodule ExIrc.UtilsTest do } = Utils.parse(':WiZ!jto@tolsun.oulu.fi NICK Kilroy') end + test "Can parse prefix with only hostname in messages" do + assert %IrcMessage{ + nick: "WiZ", + host: "tolsun.oulu.fi", + } = Utils.parse(':WiZ!tolsun.oulu.fi NICK Kilroy') + end + test "Can parse reduced prefix in messages" do assert %IrcMessage{ nick: "Trillian", |