mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 06:14:47 +03:00
Allow format suffixes after trailing slash
This commit is contained in:
parent
1b53e804ee
commit
486a8f82b2
|
@ -23,7 +23,10 @@ def apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Regular URL pattern
|
# Regular URL pattern
|
||||||
regex = urlpattern.regex.pattern.rstrip('$').rstrip('/') + suffix_pattern
|
regex = urlpattern.regex.pattern.rstrip('$')
|
||||||
|
if regex[-1:] == '/':
|
||||||
|
regex += '?'
|
||||||
|
regex += suffix_pattern
|
||||||
view = urlpattern._callback or urlpattern._callback_str
|
view = urlpattern._callback or urlpattern._callback_str
|
||||||
kwargs = urlpattern.default_args
|
kwargs = urlpattern.default_args
|
||||||
name = urlpattern.name
|
name = urlpattern.name
|
||||||
|
|
|
@ -47,7 +47,7 @@ class FormatSuffixTests(TestCase):
|
||||||
|
|
||||||
test_paths = [
|
test_paths = [
|
||||||
(URLTestPath('/test.api', (), {'format': 'api'}), True),
|
(URLTestPath('/test.api', (), {'format': 'api'}), True),
|
||||||
(URLTestPath('/test/.api', (), {'format': 'api'}), False),
|
(URLTestPath('/test/.api', (), {'format': 'api'}), True),
|
||||||
(URLTestPath('/test.api/', (), {'format': 'api'}), True),
|
(URLTestPath('/test.api/', (), {'format': 'api'}), True),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user