Tweak the webfinger resolution

This commit is contained in:
Thomas Sileo
2018-05-25 23:57:29 +02:00
parent d90e489fc6
commit 06f4f824d8
4 changed files with 52 additions and 30 deletions

View File

@@ -9,6 +9,10 @@ from . import strtobool
logger = logging.getLogger(__name__)
class InvalidURLError(Exception):
pass
def is_url_valid(url: str) -> bool:
parsed = urlparse(url)
if parsed.scheme not in ['http', 'https']:
@@ -33,3 +37,10 @@ def is_url_valid(url: str) -> bool:
return False
return True
def check_url(url: str) -> None:
if not is_url_valid(url):
raise InvalidURLError(f'"{url}" is invalid')
return None