File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -476,7 +476,7 @@ export function hasImageInRule(rule) {
476476 * @return {Array }
477477 */
478478export function getImageUrl ( rule ) {
479- const matches = / b a c k g r o u n d [ ^ : ] * : . * u r l \( ( [ \S ] + ) \ )/ gi. exec ( rule ) ;
479+ const matches = / u r l (?: \( [ ' " ] ? ) ( . * ? ) (?: [ ' " ] ? \) ) / gi. exec ( rule ) ;
480480 let original = '' ;
481481 let normalized = '' ;
482482
Original file line number Diff line number Diff line change @@ -44,6 +44,16 @@ test('should return the url of an image', (t) => {
4444 t . deepEqual ( getImageUrl ( backgroundColor ) [ 1 ] , '' ) ;
4545} ) ;
4646
47+ test ( 'shoud return the url of an image in compressed CSS rules' , ( t ) => {
48+ const background = '.selector-a{background:url(square.png) no-repeat 0 0;transform:scale(0.5)}' ;
49+ const backgroundImage = '.selector-a{background-image:url(square.png);transform:scale(0.5)}' ;
50+ const backgroundColor = '.selector-a{background:#fff;transform:scale(0.5)}' ;
51+
52+ t . deepEqual ( getImageUrl ( background ) [ 1 ] , 'square.png' ) ;
53+ t . deepEqual ( getImageUrl ( backgroundImage ) [ 1 ] , 'square.png' ) ;
54+ t . deepEqual ( getImageUrl ( backgroundColor ) [ 1 ] , '' ) ;
55+ } ) ;
56+
4757test ( 'should remove get params' , ( t ) => {
4858 const background = '.selector-b { background: url(square.png?v1234) no-repeat 0 0; }' ;
4959 t . deepEqual ( getImageUrl ( background ) [ 1 ] , 'square.png' ) ;
You can’t perform that action at this time.
0 commit comments