Skip to content

Commit

Permalink
Apply PR callumlocke#7: Fix of big Regexp issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joakim committed Oct 14, 2014
1 parent e8e4a85 commit 1c95e1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions 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 = /@import[^;]*|[;\s]?\*?[a-zA-Z\-]+\s*\:\#?[\s\S]*url\(\s*['"]?[^'"\)\s]+['"]?\s*\)[^;}]*/g;
var cssPropertyMatcher = /@import[^;]*|[;\s]?\*?[a-zA-Z\-]+\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 All @@ -32,7 +32,7 @@ module.exports = function rewriteCSSURLs(css, settings, rewriterFn) {
settings = extend({}, defaults, settings);

// Return the modified CSS
var result = css.toString().replace(cssPropertyMatcher, function(property, urlValue) {
var result = css.toString().replace(cssPropertyMatcher, function(property) {
// This function deals with an individual CSS property.

// If this property is excluded, return it unchanged
Expand Down
17 changes: 11 additions & 6 deletions test/expected/msie-behavior.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/* URLs in IE's 'behavior' property are skipped, by default */
/* URLs in IE's 'behavior' property are skipped, by default
* We'll test skipping of 'behavior' and processing 'notbehavior'
*/
*, *:before, *:after {
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 );
notbehavior: url(_scripts/boxsizing.htc);
notbehavior : url( _scripts/boxsizing.htc );

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

.thing {
Expand Down
11 changes: 8 additions & 3 deletions test/fixtures/msie-behavior.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/* URLs in IE's 'behavior' property are skipped, by default */
/* URLs in IE's 'behavior' property are skipped, by default
* We'll test skipping of 'behavior' and processing 'notbehavior'
*/
*, *:before, *:after {
box-sizing: border-box;

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

notbehavior: url(scripts/boxsizing.htc);
notbehavior : url( scripts/boxsizing.htc );

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

.thing {
Expand Down

0 comments on commit 1c95e1e

Please sign in to comment.