Spaces:
Sleeping
Sleeping
from urllib.parse import urlparse | |
import validators | |
def valid_url(url): | |
try: | |
parsed_url = urlparse(url) | |
# Check if scheme is missing and prepend 'https://' if so | |
if not parsed_url.scheme: | |
url = 'https://' + url | |
# Validate the modified or original URL | |
return validators.url(url), url | |
except: | |
return False, url | |