diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 21ce5c1c360..c82421c152c 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -148,6 +148,15 @@ def redirect_to(*args, **kw): toolkit.redirect_to('dataset_read', id='changed') ''' + # Remove LANG from root_path so that we do not need to parse locales + root_path = config.get('ckan.root_path', None) + if root_path: + root_path = re.sub('/{{LANG}}', '', root_path) + + # If args contain full url eg. http://example.com or url starting with root_path skip url parsing + if args and (is_url(args[0]) or ( root_path and args[0].startswith(root_path))) : + _routes_redirect_to(args[0]) + if are_there_flash_messages(): kw['__no_cache__'] = True return _redirect_to(url_for(*args, **kw))