Don't consume .json style suffixes with routers.

When trailing slash is false, the lookup regex should not consume '.'
characters.  Fixes #1057.
This commit is contained in:
Tom Christie 2013-08-23 14:58:06 +01:00
parent f54fc3a76b
commit 005f475c6a

View File

@ -189,7 +189,11 @@ class SimpleRouter(BaseRouter):
Given a viewset, return the portion of URL regex that is used
to match against a single instance.
"""
base_regex = '(?P<{lookup_field}>[^/]+)'
if self.trailing_slash:
base_regex = '(?P<{lookup_field}>[^/]+)'
else:
# Don't consume `.json` style suffixes
base_regex = '(?P<{lookup_field}>[^/.]+)'
lookup_field = getattr(viewset, 'lookup_field', 'pk')
return base_regex.format(lookup_field=lookup_field)