Tidy-Tabs-Titles / utils.py
wgcv's picture
first test
b7a1a13
raw
history blame
378 Bytes
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