Skip to content

Commit 2cdb72a

Browse files
committed
Fix css url detector regex.
1 parent f78d3e0 commit 2cdb72a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

pipeline/compressors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pipeline.exceptions import CompressorError
1717
from pipeline.utils import to_class, relpath, set_std_streams_blocking
1818

19-
URL_DETECTOR = r"""url\((['"]){0,1}\s*(.*?)["']{0,1}\)"""
19+
URL_DETECTOR = r"""url\((['"]?)\s*(.*?)\1\)"""
2020
URL_REPLACER = r"""url\(__EMBED__(.+?)(\?\d+)?\)"""
2121
NON_REWRITABLE_URL = re.compile(r'^(#|http:|https:|data:|//)')
2222

tests/assets/css/urls.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.embedded-url-svg {
2+
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E% 3C/svg%3E");
3+
}
14
@font-face {
25
font-family: 'Pipeline';
36
src: url('../fonts/pipeline.eot');

tests/tests/test_compressor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ def test_url_rewrite(self):
138138
output = self.compressor.concatenate_and_rewrite([
139139
_('pipeline/css/urls.css'),
140140
], 'css/screen.css')
141-
self.assertEqual("""@font-face {
141+
self.assertEqual(""".embedded-url-svg {
142+
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E% 3C/svg%3E");
143+
}
144+
@font-face {
142145
font-family: 'Pipeline';
143146
src: url(../pipeline/fonts/pipeline.eot);
144147
src: url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype');

0 commit comments

Comments
 (0)