mirror of
https://github.com/django/django.git
synced 2025-06-07 12:39:12 +00:00
[2.0.x] Merged startswith() calls.
Backport of 00709d704ee75ace99c4a81aa60e029caeeac387 from master
This commit is contained in:
parent
e241b4e797
commit
c67dce911e
@ -246,7 +246,7 @@ def construct_relative_path(current_template_name, relative_name):
|
|||||||
Convert a relative path (starting with './' or '../') to the full template
|
Convert a relative path (starting with './' or '../') to the full template
|
||||||
name based on the current_template_name.
|
name based on the current_template_name.
|
||||||
"""
|
"""
|
||||||
if not any(relative_name.startswith(x) for x in ["'./", "'../", '"./', '"../']):
|
if not relative_name.startswith(("'./", "'../", '"./', '"../')):
|
||||||
# relative_name is a variable or a literal that doesn't contain a
|
# relative_name is a variable or a literal that doesn't contain a
|
||||||
# relative path.
|
# relative path.
|
||||||
return relative_name
|
return relative_name
|
||||||
|
@ -119,7 +119,7 @@ class CheckURLMixin:
|
|||||||
# Skip check as it can be useful to start a URL pattern with a slash
|
# Skip check as it can be useful to start a URL pattern with a slash
|
||||||
# when APPEND_SLASH=False.
|
# when APPEND_SLASH=False.
|
||||||
return []
|
return []
|
||||||
if any(regex_pattern.startswith(x) for x in ('/', '^/', '^\/')) and not regex_pattern.endswith('/'):
|
if regex_pattern.startswith(('/', '^/', '^\/')) and not regex_pattern.endswith('/'):
|
||||||
warning = Warning(
|
warning = Warning(
|
||||||
"Your URL pattern {} has a route beginning with a '/'. Remove this "
|
"Your URL pattern {} has a route beginning with a '/'. Remove this "
|
||||||
"slash as it is unnecessary. If this pattern is targeted in an "
|
"slash as it is unnecessary. If this pattern is targeted in an "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user