Skip to content

Commit

Permalink
Improve properties detection: Now we can detect: * @import * Properti…
Browse files Browse the repository at this point in the history
…es that have different values before the 'url('.
  • Loading branch information
Tomás Corral authored and callumlocke committed Jul 1, 2014
1 parent 6118ae4 commit 29e5889
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/css-url-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var extend = require('extend');
// Regex to find CSS properties that contain URLs
// Fiddle: http://refiddle.com/refiddles/css-url-matcher
// Railroad: http://goo.gl/LXpk52
var cssPropertyMatcher = /[;\s]\*?[a-zA-Z\-]+\s*\:\s*url\(\s*['"]?[^'"\)\s]+['"]?\s*\)[^;}]*/g;
var cssPropertyMatcher = /@import[^;]*|[;\s]?\*?[a-zA-Z\-]+\s*\:\#?[\s\S]*url\(\s*['"]?[^'"\)\s]+['"]?\s*\)[^;}]*/g;

// Regex to find the URLs within a CSS property value
// Fiddle: http://refiddle.com/refiddles/match-multiple-urls-within-a-css-property-value
Expand Down
1 change: 0 additions & 1 deletion test/css-url-rewriter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = {
expected = fs.readFileSync(expectedFile).toString();

var result = rewriteCSSURLs(fixture, rewrite);

if (SAVE)
fs.writeFileSync(path.join(__dirname, 'results', basename), result);

Expand Down
5 changes: 4 additions & 1 deletion test/expected/general.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
@import url("_../stylesheet.css");
.something {
background: url('_../images/foo.png');
background: url('_../images/bar.png?12345');
background: url(_../images/foo.png) ;
background: url( _../images/bar.png );
background: url(
_../images/bar.png
)
);
background: transparent url( _../images/bar.png );
background: #EEEEEE url( _../images/bar.png );
}

.another-thing {
Expand Down
6 changes: 3 additions & 3 deletions test/expected/msie-behavior.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
box-sizing: border-box;

/* without hack */
behavior: url(scripts/boxsizing.htc);
behavior : url( scripts/boxsizing.htc );
behavior: url(_scripts/boxsizing.htc);
behavior : url( _scripts/boxsizing.htc );

/* with IE<8 hack */
*behavior: url(scripts/boxsizing.htc);
*behavior: url(_scripts/boxsizing.htc);
}

.thing {
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/general.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
@import url("../stylesheet.css");
.something {
background: url('../images/foo.png');
background: url('../images/bar.png?12345');
background: url(../images/foo.png) ;
background: url( ../images/bar.png );
background: url(
../images/bar.png
)
);
background: transparent url( ../images/bar.png );
background: #EEEEEE url( ../images/bar.png );
}

.another-thing {
Expand Down

0 comments on commit 29e5889

Please sign in to comment.