File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
- var embeddedRegexp = / d a t a : ( .* ?) ; b a s e 6 4 , / ;
1
+ var embeddedRegexp = / ^ d a t a : ( .* ?) , ( . * ? ) / ;
2
2
var commentRegexp = / \/ \* ( [ \s \S ] * ?) \* \/ / g;
3
3
var urlsRegexp = / ( (?: @ i m p o r t \s + ) ? u r l \s * \( \s * [ ' " ] ? ) ( .* ?) ( [ ' " ] ? \s * \) ) | ( @ i m p o r t \s + [ ' " ] ? ) ( [ ^ ; ' " ] + ) / ig;
4
4
5
5
function isEmbedded ( src ) {
6
- return embeddedRegexp . test ( src ) ;
6
+ return embeddedRegexp . test ( src . trim ( ) ) ;
7
7
}
8
8
9
9
function getUrls ( text ) {
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ describe('Parse css urls', function(){
121
121
} ) ;
122
122
} ) ;
123
123
124
- describe ( 'base64 dataURI ' , function ( ) {
124
+ describe ( 'Data URI ' , function ( ) {
125
125
it ( 'should ignore base64 encoded images' , function ( ) {
126
126
var text = '\
127
127
div.image { \
@@ -150,5 +150,23 @@ describe('Parse css urls', function(){
150
150
urls . should . be . instanceof ( Array ) ;
151
151
urls . should . have . length ( 0 ) ;
152
152
} ) ;
153
+
154
+ it ( 'should ignore utf-8 encoded data uri' , function ( ) {
155
+ var text = 'img.grayscale { \
156
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'></svg>"); \
157
+ }' ;
158
+ var urls = parseCssUrls ( text ) ;
159
+ urls . should . be . instanceof ( Array ) ;
160
+ urls . should . have . length ( 0 ) ;
161
+ } ) ;
162
+
163
+ it ( 'should ignore minimal data uri ("data:,")' , function ( ) {
164
+ var text = 'img.grayscale { \
165
+ filter: url("data:,"); \
166
+ }' ;
167
+ var urls = parseCssUrls ( text ) ;
168
+ urls . should . be . instanceof ( Array ) ;
169
+ urls . should . have . length ( 0 ) ;
170
+ } )
153
171
} ) ;
154
172
} ) ;
You can’t perform that action at this time.
0 commit comments