diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index 1e5c3db..eab5891 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -15,7 +15,7 @@ defmodule Linkify.Parser do # @user # @user@example.com - @match_mention ~r"^@[a-zA-Z\d_-]+@[a-zA-Z0-9_-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*|@[a-zA-Z\d_-]+"u + @match_mention ~r"^@[a-zA-Z\d_-]+@[a-zA-Z0-9_-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*|^@[a-zA-Z\d_-]+"u # https://www.w3.org/TR/html5/forms.html#valid-e-mail-address @match_email ~r"^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"u diff --git a/test/linkify_test.exs b/test/linkify_test.exs index b5059f6..a18dc3c 100644 --- a/test/linkify_test.exs +++ b/test/linkify_test.exs @@ -385,6 +385,12 @@ defmodule LinkifyTest do mention_prefix: "https://example.com/user/" ) == expected end + + test "invalid mentions" do + text = "hey user@example" + + assert Linkify.link(text, mention: true, mention_prefix: "/users/") == text + end end describe "hashtag links" do