From 1c95e1ef5b38fbd930012878be16a031af88dafd Mon Sep 17 00:00:00 2001 From: Joakim Stai Date: Tue, 14 Oct 2014 14:55:05 +0200 Subject: [PATCH] Apply PR #7: Fix of big Regexp issue --- lib/css-url-rewriter.js | 4 ++-- test/expected/msie-behavior.css | 17 +++++++++++------ test/fixtures/msie-behavior.css | 11 ++++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/css-url-rewriter.js b/lib/css-url-rewriter.js index ac8b27d..42901ff 100644 --- a/lib/css-url-rewriter.js +++ b/lib/css-url-rewriter.js @@ -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 @@ -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 diff --git a/test/expected/msie-behavior.css b/test/expected/msie-behavior.css index 285fa67..c26ade8 100644 --- a/test/expected/msie-behavior.css +++ b/test/expected/msie-behavior.css @@ -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 { diff --git a/test/fixtures/msie-behavior.css b/test/fixtures/msie-behavior.css index 1ff77d8..6190216 100644 --- a/test/fixtures/msie-behavior.css +++ b/test/fixtures/msie-behavior.css @@ -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 {