mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-08 07:33:23 +03:00
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:
parent
f54fc3a76b
commit
005f475c6a
|
@ -189,7 +189,11 @@ class SimpleRouter(BaseRouter):
|
||||||
Given a viewset, return the portion of URL regex that is used
|
Given a viewset, return the portion of URL regex that is used
|
||||||
to match against a single instance.
|
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')
|
lookup_field = getattr(viewset, 'lookup_field', 'pk')
|
||||||
return base_regex.format(lookup_field=lookup_field)
|
return base_regex.format(lookup_field=lookup_field)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user