Fix trailing parentheses in URLs not being detected

Also fix URLs starting near the end of the line not being detected.

Fixes #3688
This commit is contained in:
Kovid Goyal
2021-06-04 18:13:36 +05:30
parent a8d1c73fec
commit 81411e6b54
8 changed files with 124 additions and 86 deletions

View File

@@ -243,13 +243,16 @@ class TestDataTypes(BaseTest):
l0 = create('file:///etc/test')
self.ae(l0.url_start_at(0), 0)
for trail in '.,]>)\\':
for trail in '.,\\':
lx = create("http://xyz.com" + trail)
self.ae(lx.url_end_at(0), len(lx) - 2)
for trail in ')}]>':
lx = create("http://xyz.com" + trail)
self.ae(lx.url_end_at(0), len(lx) - 1)
l0 = create("ftp://abc/")
self.ae(l0.url_end_at(0), len(l0) - 1)
l2 = create("http://-abcd] ")
self.ae(l2.url_end_at(0), len(l2) - 3)
self.ae(l2.url_end_at(0), len(l2) - 2)
l3 = create("http://ab.de ")
self.ae(l3.url_start_at(4), 0)
self.ae(l3.url_start_at(5), 0)