response to comments

This commit is contained in:
Jeremy Langley 2022-03-04 00:11:59 -08:00
parent d31d428c97
commit a35b946150
3 changed files with 5 additions and 5 deletions

View File

@ -254,7 +254,7 @@ class SimpleRouter(BaseRouter):
# so a slash in the beginning will (A) cause Django to give
# warnings and (B) generate URLS that will require using '//'.
if not prefix and regex[:2] == '^/':
regex = f'^{regex[2:]}'
regex = '^' + regex[2:]
initkwargs = route.initkwargs.copy()
initkwargs.update({

View File

@ -11,7 +11,7 @@ def _get_format_path_converter(suffix_kwarg, allowed):
else:
allowed_cases = "|".join(allowed)
allowed_pattern = f'(?:{allowed_cases})'
suffix_pattern = fr"\.{allowed_pattern}/?"
suffix_pattern = r"\.%s/?" % allowed_pattern
else:
suffix_pattern = r"\.[a-z0-9]+/?"
@ -102,9 +102,9 @@ def format_suffix_patterns(urlpatterns, suffix_required=False, allowed=None):
else:
allowed_cases = "|".join(allowed)
allowed_pattern = f'({allowed_cases})'
suffix_pattern = fr'\.(?P<{suffix_kwarg}>{allowed_pattern})/?$'
suffix_pattern = r'\.(?P<%s>%s)/?$' % (suffix_kwarg, allowed_pattern)
else:
suffix_pattern = fr'\.(?P<{suffix_kwarg}>[a-z0-9]+)/?$'
suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg
converter_name, suffix_converter = _get_format_path_converter(suffix_kwarg, allowed)
register_converter(suffix_converter, converter_name)

View File

@ -83,7 +83,7 @@ def parse_html_dict(dictionary, prefix=''):
}
"""
ret = MultiValueDict()
regex = re.compile(fr'^{re.escape(prefix)}\.(.+)$')
regex = re.compile(r'^%s\.(.+)$' % re.escape(prefix))
for field in dictionary:
match = regex.match(field)
if not match: