mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #29796 -- Added system check for STATICFILES_DIRS prefix ending with a slash.
This commit is contained in:
parent
40c8ffad72
commit
05c578bc1f
@ -78,7 +78,13 @@ class FileSystemFinder(BaseFinder):
|
||||
))
|
||||
for root in settings.STATICFILES_DIRS:
|
||||
if isinstance(root, (list, tuple)):
|
||||
_, root = root
|
||||
prefix, root = root
|
||||
if prefix.endswith('/'):
|
||||
errors.append(Error(
|
||||
'The prefix %r in the STATICFILES_DIRS setting must '
|
||||
'not end with a slash.' % prefix,
|
||||
id='staticfiles.E003',
|
||||
))
|
||||
if settings.STATIC_ROOT and os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
|
||||
errors.append(Error(
|
||||
'The STATICFILES_DIRS setting should not contain the '
|
||||
|
@ -731,3 +731,5 @@ configured:
|
||||
or list.
|
||||
* **staticfiles.E002**: The :setting:`STATICFILES_DIRS` setting should not
|
||||
contain the :setting:`STATIC_ROOT` setting.
|
||||
* **staticfiles.E003**: The prefix ``<prefix>`` in the
|
||||
:setting:`STATICFILES_DIRS` setting must not end with a slash.
|
||||
|
@ -75,3 +75,13 @@ class FindersCheckTests(SimpleTestCase):
|
||||
id='staticfiles.E002',
|
||||
)
|
||||
])
|
||||
|
||||
@override_settings(STATICFILES_DIRS=[('prefix/', '/fake/path')])
|
||||
def test_prefix_contains_trailing_slash(self):
|
||||
self.assertEqual(check_finders(None), [
|
||||
Error(
|
||||
"The prefix 'prefix/' in the STATICFILES_DIRS setting must "
|
||||
"not end with a slash.",
|
||||
id='staticfiles.E003',
|
||||
)
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user