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
|
||||||
# @user@example.com
|
# @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
|
# 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
|
@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/"
|
mention_prefix: "https://example.com/user/"
|
||||||
) == expected
|
) == expected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "invalid mentions" do
|
||||||
|
text = "hey user@example"
|
||||||
|
|
||||||
|
assert Linkify.link(text, mention: true, mention_prefix: "/users/") == text
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "hashtag links" do
|
describe "hashtag links" do
|
||||||
|
|
Reference in a new issue