Update rest_framework/urlpatterns.py

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

View File

@ -9,7 +9,8 @@ def _get_format_path_converter(suffix_kwarg, allowed):
if len(allowed) == 1:
allowed_pattern = allowed[0]
else:
allowed_pattern = f'(?:{"|".join(allowed)})'
allowed_cases = "|".join(allowed)
allowed_pattern = f'(?:{allowed_cases})'
suffix_pattern = r"\.%s/?" % allowed_pattern
else:
suffix_pattern = r"\.[a-z0-9]+/?"