diff --git a/bookwyrm/outgoing.py b/bookwyrm/outgoing.py index bc170748..9421ca39 100644 --- a/bookwyrm/outgoing.py +++ b/bookwyrm/outgoing.py @@ -296,7 +296,7 @@ def find_mentions(content): def format_links(content): ''' detect and format links ''' return re.sub( - r'([^(href=")]|^)(https?:\/\/(%s([\w\.\-_\/+&\?=:;,])*))' % \ + r'([^(href=")]|^|\()(https?:\/\/(%s([\w\.\-_\/+&\?=:;,])*))' % \ regex.domain, r'\g<1>\g<3>', content) diff --git a/bookwyrm/tests/test_outgoing.py b/bookwyrm/tests/test_outgoing.py index ba0d7d7d..c4324773 100644 --- a/bookwyrm/tests/test_outgoing.py +++ b/bookwyrm/tests/test_outgoing.py @@ -497,6 +497,9 @@ class Outgoing(TestCase): self.assertEqual( outgoing.format_links(url), 'www.fish.com/' % url) + self.assertEqual( + outgoing.format_links('(%s)' % url), + '(www.fish.com/)' % url) url = 'https://archive.org/details/dli.granth.72113/page/n25/mode/2up' self.assertEqual( outgoing.format_links(url),