Merge pull request #319 from jangsutsr/7496_handle_empty_named_url_id_cornercase

Handle named URL processing corner case where identifier is empty string
This commit is contained in:
Aaron Tan 2017-08-22 14:25:06 -04:00 committed by GitHub
commit c2e8200c81

View File

@ -143,7 +143,8 @@ class URLModificationMiddleware(object):
def _convert_named_url(self, url_path):
url_units = url_path.split('/')
if len(url_units) < 6 or url_units[1] != 'api' or url_units[2] not in ['v2']:
# If the identifier is an empty string, it is always invalid.
if len(url_units) < 6 or url_units[1] != 'api' or url_units[2] not in ['v2'] or not url_units[4]:
return url_path
resource = url_units[3]
if resource in settings.NAMED_URL_MAPPINGS: