raise url string parsing error as validation error

This commit is contained in:
Jake McDermott
2019-05-01 08:56:56 -04:00
parent 9737ab620c
commit 84b21620b2
2 changed files with 14 additions and 4 deletions

View File

@@ -492,7 +492,11 @@ def format_ssh_private_key(value):
@JSONSchemaField.format_checker.checks('url')
def format_url(value):
if urllib.parse.urlparse(value).scheme == '':
try:
scheme = urllib.parse.urlparse(value).scheme
except Exception as e:
raise jsonschema.exceptions.FormatError(str(e))
if scheme == '':
raise jsonschema.exceptions.FormatError(
'Invalid URL: Missing url scheme (http, https, etc.)'
)