Skip to content

Commit 52c6101

Browse files
committed
Fix t.co urls followed by a comma
1 parent bdf7316 commit 52c6101

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ttp/tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ def test_url_followed_comma(self):
231231
self.assertEqual(result.html, u'text <a href="http://example.com">http://example.com</a>,')
232232
self.assertEqual(result.urls, [u'http://example.com'])
233233

234+
def test_url_with_path_followed_comma(self):
235+
result = self.parser.parse(u'text http://example.com/abcde, more')
236+
self.assertEqual(result.html, u'text <a href="http://example.com/abcde">http://example.com/abcde</a>, more')
237+
self.assertEqual(result.urls, [u'http://example.com/abcde'])
238+
234239
def test_url_followed_brace(self):
235240
result = self.parser.parse(u'text http://example.com)')
236241
self.assertEqual(result.html, u'text <a href="http://example.com">http://example.com</a>)')

ttp/ttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
PATH_ENDING_CHARS = r'[%s\)=#/]' % UTF_CHARS
6060
QUERY_ENDING_CHARS = '[a-z0-9_&=#]'
6161

62-
URL_REGEX = re.compile('((%s)((https?://|www\\.)(%s)(\/%s*%s?)?(\?%s*%s)?))'
62+
URL_REGEX = re.compile('((%s)((https?://|www\\.)(%s)(\/(%s*%s)?)?(\?%s*%s)?))'
6363
% (PRE_CHARS, DOMAIN_CHARS, PATH_CHARS,
6464
PATH_ENDING_CHARS, QUERY_CHARS, QUERY_ENDING_CHARS),
6565
re.IGNORECASE)

0 commit comments

Comments
 (0)