Skip to content
Snippets Groups Projects
Commit 710640ec authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

check if adding scheme makes a valid URL

parent 894c82ee
No related branches found
No related tags found
1 merge request!134Refactor
This commit is part of merge request !134. Comments created here will be created in the context of that merge request.
...@@ -46,8 +46,11 @@ def extract_urls(text: str) -> List[str]: ...@@ -46,8 +46,11 @@ def extract_urls(text: str) -> List[str]:
def valid_url(url: str) -> bool: def valid_url(url: str) -> bool:
try: try:
parsed = url_parse(url) parsed = url_parse(url)
valid = bool(parsed) valid = bool(parsed)
if not valid:
# if it's valid with the scheme added, then we're fine
parsed = url_parse('http://' + url)
valid = bool(parsed)
except Exception: except Exception:
valid = False valid = False
return valid return valid
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment