Allow format suffixes after trailing slash

This commit is contained in:
David Sutherland 2015-08-17 10:29:09 +10:00
parent 1b53e804ee
commit 486a8f82b2
2 changed files with 5 additions and 2 deletions

View File

@ -23,7 +23,10 @@ def apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required):
else:
# 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
kwargs = urlpattern.default_args
name = urlpattern.name

View File

@ -47,7 +47,7 @@ class FormatSuffixTests(TestCase):
test_paths = [
(URLTestPath('/test.api', (), {'format': 'api'}), True),
(URLTestPath('/test/.api', (), {'format': 'api'}), False),
(URLTestPath('/test/.api', (), {'format': 'api'}), True),
(URLTestPath('/test.api/', (), {'format': 'api'}), True),
]