Don't treat single words as URL
This commit is contained in:
parent
8e122abd35
commit
7fb0a7745b
@ -137,6 +137,7 @@ class IsUrlNaiveTests(TestCase):
|
|||||||
'foo bar',
|
'foo bar',
|
||||||
'localhost test',
|
'localhost test',
|
||||||
'another . test',
|
'another . test',
|
||||||
|
'foo',
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_urls(self):
|
def test_urls(self):
|
||||||
|
@ -73,11 +73,14 @@ def _is_url_naive(url):
|
|||||||
True if the url really is an URL, False otherwise.
|
True if the url really is an URL, False otherwise.
|
||||||
"""
|
"""
|
||||||
protocols = ['http', 'https']
|
protocols = ['http', 'https']
|
||||||
|
u = qurl(url)
|
||||||
|
urlstr = urlstring(url)
|
||||||
if isinstance(url, QUrl):
|
if isinstance(url, QUrl):
|
||||||
u = url
|
u = url
|
||||||
else:
|
else:
|
||||||
u = QUrl.fromUserInput(url)
|
u = QUrl.fromUserInput(url)
|
||||||
if u.scheme() in protocols:
|
# We don't use u here because fromUserInput appends http:// automatically.
|
||||||
|
if any(urlstr.startswith(proto) for proto in protocols):
|
||||||
return True
|
return True
|
||||||
elif '.' in u.host():
|
elif '.' in u.host():
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user