diff --git a/bookwyrm/tests/views/test_status.py b/bookwyrm/tests/views/test_status.py
index 33bd8b53a..6e630a370 100644
--- a/bookwyrm/tests/views/test_status.py
+++ b/bookwyrm/tests/views/test_status.py
@@ -436,6 +436,15 @@ http://www.fish.com/"""
f'www.fish.com/.',
)
+ def test_format_links_punctuation_parens(self, *_):
+ """ignore trailing punctuation and brackets combined"""
+ # Period at the end, wrapped in brackets.
+ url = "http://www.fish.com"
+ self.assertEqual(
+ views.status.format_links(f"({url})."),
+ f'(www.fish.com).',
+ )
+
def test_format_links_special_chars(self, *_):
"""find and format urls into a tags"""
url = "https://archive.org/details/dli.granth.72113/page/n25/mode/2up"
diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py
index 7a0517b01..196db4eb9 100644
--- a/bookwyrm/views/status.py
+++ b/bookwyrm/views/status.py
@@ -304,17 +304,19 @@ def format_links(content):
for potential_link in split_content:
if not potential_link:
continue
+
+ # FIXME: allow for multiple punctuation characters, e.g. `...` and `!?`.
+ ends_with_punctuation = _ends_with_punctuation(potential_link)
+ if ends_with_punctuation:
+ punctuation_glyph = potential_link[-1]
+ potential_link = potential_link[0:-1]
+
wrapped = _wrapped(potential_link)
if wrapped:
wrapper_close = potential_link[-1]
formatted_content += potential_link[0]
potential_link = potential_link[1:-1]
- ends_with_punctuation = _ends_with_punctuation(potential_link)
- if ends_with_punctuation:
- punctuation_glyph = potential_link[-1]
- potential_link = potential_link[0:-1]
-
try:
# raises an error on anything that's not a valid link
validator(potential_link)