mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-26 18:10:36 +00:00
Merge pull request #505 from mouse-reeve/link-regex-parens
Work around parens in the url regex
This commit is contained in:
commit
9a575beb0b
2 changed files with 4 additions and 1 deletions
|
@ -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><a href="\g<2>">\g<3></a>',
|
||||
content)
|
||||
|
|
|
@ -497,6 +497,9 @@ class Outgoing(TestCase):
|
|||
self.assertEqual(
|
||||
outgoing.format_links(url),
|
||||
'<a href="%s">www.fish.com/</a>' % url)
|
||||
self.assertEqual(
|
||||
outgoing.format_links('(%s)' % url),
|
||||
'(<a href="%s">www.fish.com/</a>)' % url)
|
||||
url = 'https://archive.org/details/dli.granth.72113/page/n25/mode/2up'
|
||||
self.assertEqual(
|
||||
outgoing.format_links(url),
|
||||
|
|
Loading…
Reference in a new issue