Fix is_url('https://ultralytics.com') (#9610)
Failing on missing path, i.e. no 'www.' Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
6b2c9d1d0f
commit
1460e57157
1 file changed
+1
-1
+1
-1
@@ -21,7 +21,7 @@ def is_url(url, check=True):
|
|||||||
try:
|
try:
|
||||||
url = str(url)
|
url = str(url)
|
||||||
result = urllib.parse.urlparse(url)
|
result = urllib.parse.urlparse(url)
|
||||||
assert all([result.scheme, result.netloc, result.path]) # check if is url
|
assert all([result.scheme, result.netloc]) # check if is url
|
||||||
return (urllib.request.urlopen(url).getcode() == 200) if check else True # check if exists online
|
return (urllib.request.urlopen(url).getcode() == 200) if check else True # check if exists online
|
||||||
except (AssertionError, urllib.request.HTTPError):
|
except (AssertionError, urllib.request.HTTPError):
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in new issue
Block a user