mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 08:41:00 +00:00
parent
c969ffc0d6
commit
294095c592
2 changed files with 14 additions and 1 deletions
|
@ -342,7 +342,7 @@ class Post(StatorModel):
|
|||
PostTypeData.parse_obj(value)
|
||||
|
||||
mention_regex = re.compile(
|
||||
r"(^|[^\w\d\-_/])@([\w\d\-_]+(?:@[\w\d\-_]+\.[\w\d\-_\.]+)?)"
|
||||
r"(^|[^\w\d\-_/])@([\w\d\-_]+(?:@[\w\d\-_\.]+[\w\d\-_]+)?)"
|
||||
)
|
||||
|
||||
def linkify_mentions(self, content: str, local: bool = False) -> str:
|
||||
|
|
|
@ -77,6 +77,7 @@ def test_linkify_mentions_remote(
|
|||
local=True,
|
||||
)
|
||||
assert post.safe_content_remote() == "<p>@test@example.com, welcome!</p>"
|
||||
|
||||
# Test case insensitivity (remote)
|
||||
post = Post.objects.create(
|
||||
content="<p>Hey @TeSt</p>",
|
||||
|
@ -89,6 +90,18 @@ def test_linkify_mentions_remote(
|
|||
== '<p>Hey <a href="https://remote.test/@test/">@test</a></p>'
|
||||
)
|
||||
|
||||
# Test trailing dot (remote)
|
||||
post = Post.objects.create(
|
||||
content="<p>Hey @test@remote.test.</p>",
|
||||
author=identity,
|
||||
local=True,
|
||||
)
|
||||
post.mentions.add(remote_identity)
|
||||
assert (
|
||||
post.safe_content_remote()
|
||||
== '<p>Hey <a href="https://remote.test/@test/">@test</a>.</p>'
|
||||
)
|
||||
|
||||
# Test that collapsing only applies to the first unique, short username
|
||||
post = Post.objects.create(
|
||||
content="<p>Hey @TeSt@remote.test and @test@remote2.test</p>",
|
||||
|
|
Loading…
Reference in a new issue