Update rest_framework/urlpatterns.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
This commit is contained in:
Jeremy Langley 2022-02-28 20:53:01 -08:00 committed by GitHub
parent f02d346ec0
commit 431830261b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,7 +100,8 @@ def format_suffix_patterns(urlpatterns, suffix_required=False, allowed=None):
if len(allowed) == 1: if len(allowed) == 1:
allowed_pattern = allowed[0] allowed_pattern = allowed[0]
else: else:
allowed_pattern = f'({"|".join(allowed)})' allowed_cases = "|".join(allowed)
allowed_pattern = f'({allowed_cases})'
suffix_pattern = r'\.(?P<%s>%s)/?$' % (suffix_kwarg, allowed_pattern) suffix_pattern = r'\.(?P<%s>%s)/?$' % (suffix_kwarg, allowed_pattern)
else: else:
suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg