forked from mirrors/bookwyrm
Merge pull request #491 from mouse-reeve/url-regex
Handles query params in urls
This commit is contained in:
commit
f4389b3572
2 changed files with 8 additions and 1 deletions
|
@ -296,7 +296,8 @@ def find_mentions(content):
|
|||
def format_links(content):
|
||||
''' detect and format links '''
|
||||
return re.sub(
|
||||
r'([^(href=")]|^)(https?:\/\/(%s([\w\.\-_\/])*))' % regex.domain,
|
||||
r'([^(href=")]|^)(https?:\/\/(%s([\w\.\-_\/+&\?=:;,])*))' % \
|
||||
regex.domain,
|
||||
r'\g<1><a href="\g<2>">\g<3></a>',
|
||||
content)
|
||||
|
||||
|
|
|
@ -503,3 +503,9 @@ class Outgoing(TestCase):
|
|||
'<a href="%s">' \
|
||||
'archive.org/details/dli.granth.72113/page/n25/mode/2up</a>' \
|
||||
% url)
|
||||
url = 'https://openlibrary.org/search' \
|
||||
'?q=arkady+strugatsky&mode=everything'
|
||||
self.assertEqual(
|
||||
outgoing.format_links(url),
|
||||
'<a href="%s">openlibrary.org/search' \
|
||||
'?q=arkady+strugatsky&mode=everything</a>' % url)
|
||||
|
|
Loading…
Reference in a new issue