urlpatterns: Remove unnecessary branching (#7405)

Functions path and register_converter are constants.
This commit is contained in:
John Vandenberg 2020-07-24 00:26:35 +07:00 committed by GitHub
parent 1e164c5eeb
commit 599e2b183d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,12 +105,9 @@ def format_suffix_patterns(urlpatterns, suffix_required=False, allowed=None):
else: else:
suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg
if path and register_converter: converter_name, suffix_converter = _get_format_path_converter(suffix_kwarg, allowed)
converter_name, suffix_converter = _get_format_path_converter(suffix_kwarg, allowed) register_converter(suffix_converter, converter_name)
register_converter(suffix_converter, converter_name)
suffix_route = '<%s:%s>' % (converter_name, suffix_kwarg) suffix_route = '<%s:%s>' % (converter_name, suffix_kwarg)
else:
suffix_route = None
return apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required, suffix_route) return apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required, suffix_route)