Skip to content

Commit

Permalink
Remove whitespace from resource URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelb committed Jun 25, 2014
1 parent 864f4a1 commit 4db23aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ckan/logic/converters.py
Expand Up @@ -181,3 +181,9 @@ def convert_to_json_if_string(value, context):
raise df.Invalid(_('Could not parse as valid JSON'))
else:
return value


def remove_whitespace(value, context):
if isinstance(value, basestring):
return value.strip()
return value
3 changes: 2 additions & 1 deletion ckan/logic/schema.py
Expand Up @@ -57,6 +57,7 @@
convert_package_name_or_id_to_id,
convert_group_name_or_id_to_id,
convert_to_json_if_string,
remove_whitespace,
)
from formencode.validators import OneOf
import ckan.model
Expand All @@ -69,7 +70,7 @@ def default_resource_schema():
'revision_id': [ignore_missing, unicode],
'resource_group_id': [ignore],
'package_id': [ignore],
'url': [not_empty, unicode],#, URL(add_http=False)],
'url': [not_empty, unicode, remove_whitespace],#, URL(add_http=False)],
'description': [ignore_missing, unicode],
'format': [ignore_missing, unicode],
'hash': [ignore_missing, unicode],
Expand Down

0 comments on commit 4db23aa

Please sign in to comment.