Commit 3cd6d9a4 authored by Willem ter Berg's avatar Willem ter Berg

fixed URI validation for public.version

parent 628d2872
......@@ -12,11 +12,11 @@ def is_uri(key, data, errors, context):
Checks if a given value is a valid URI. Will throw a ckan.plugins.toolkit.Invalid exception when
it cannot.
:param key:
:param data:
:param errors:
:param context:
:return:
:param key: tuple
:param data: dict
:param errors: dict
:param context: dict
:return: tuple, dict, dict, dict
"""
value = data[key]
......@@ -26,12 +26,12 @@ def is_uri(key, data, errors, context):
if isinstance(value, list):
for uri in value:
if not _valid_uri(uri):
errors[key].append('value ' + uri + 'is not a valid uri')
errors[key].append('value ' + uri + ' is not a valid uri')
return key, data, errors, context
if not _valid_uri(value):
errors[key].append('value ' + value + 'is not a valid uri')
errors[key].append('value ' + value + ' is not a valid uri')
return key, data, errors, context
......@@ -40,9 +40,9 @@ def _valid_uri(uri):
"""
Validates a given uri
:param uri:
:return:
:param uri: string
:return: bool
"""
parsed = urlparse(uri)
return all([parsed.scheme, parsed.netloc, parsed.path])
return all([parsed.scheme, parsed.netloc])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment