Skip to content

Commit cb9b19e

Browse files
committed
Fixed spacing around integrity= attribute
1 parent 72f677c commit cb9b19e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

tests/app/tests/test_webpack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ def test_integrity(self):
221221

222222
self.assertIn((
223223
'<script src="/static/django_webpack_loader_bundles/main.js" '
224-
'integrity="sha256-1wgFMxcDlOWYV727qRvWNoPHdnOGFNVMLuKd25cjR+o=">'
224+
'integrity="sha256-1wgFMxcDlOWYV727qRvWNoPHdnOGFNVMLuKd25cjR+o=" >'
225225
'</script>'), result.rendered_content)
226226
self.assertIn((
227227
'<link href="/static/django_webpack_loader_bundles/main.css" rel="stylesheet" '
228-
'integrity="sha256-cYWwRvS04/VsttQYx4BalKYrBDuw5t8vKFhWB/LKX30="/>'),
228+
'integrity="sha256-cYWwRvS04/VsttQYx4BalKYrBDuw5t8vKFhWB/LKX30=" />'),
229229
result.rendered_content
230230
)
231231

webpack_loader/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_integrity_attr(self, chunk):
4848
"The stats file does not contain valid data: INTEGRITY is set to True, "
4949
"but chunk does not contain \"integrity\" key.")
5050

51-
return 'integrity="{}"'.format(integrity.partition(' ')[0])
51+
return ' integrity="{}" '.format(integrity.partition(' ')[0])
5252

5353
def filter_chunks(self, chunks):
5454
filtered_chunks = []

webpack_loader/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@ def get_as_tags(bundle_name, extension=None, config='DEFAULT', suffix='', attrs=
7171
).format(''.join([chunk['url'], suffix]), attrs))
7272
else:
7373
tags.append((
74-
'<script src="{0}" {1}{2}></script>'
74+
'<script src="{0}"{2}{1}></script>'
7575
).format(
7676
''.join([chunk['url'], suffix]),
7777
attrs,
78-
loader.get_integrity_attr(chunk),
78+
loader.get_integrity_attr(chunk) or ' ',
7979
))
8080
elif chunk['name'].endswith(('.css', '.css.gz')):
8181
tags.append((
82-
'<link href="{0}" rel={2} {1}{3}/>'
82+
'<link href="{0}" rel={2}{3}{1}/>'
8383
).format(
8484
''.join([chunk['url'], suffix]),
8585
attrs,
8686
'"stylesheet"' if not is_preload else '"preload" as="style"',
87-
loader.get_integrity_attr(chunk),
87+
loader.get_integrity_attr(chunk) or ' ',
8888
))
8989
return tags
9090

0 commit comments

Comments
 (0)