Do not parse mention if there is something before it
This commit is contained in:
parent
5581840992
commit
e16136f709
2 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue