Skip to content

Fix parsing issues on some border line cases (qtip) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/css-url-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
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;
// https://www.experts-exchange.com/questions/27878123/Javascript-Regular-Expression-to-parse-CSS-text.html
var cssPropertyMatcher = /([\{\s]+)[a-zA-Z-]+\s*:\s*url\([^;]+\);/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 @@ -38,7 +37,7 @@ module.exports = function rewriteCSSURLs(css, settings, rewriterFn) {

// If this property is excluded, return it unchanged
if (settings.excludeProperties.length) {
var propertyName = property.split(':')[0].replace(/^\s+|\s+$/g, '');
var propertyName = property.split(':')[0].replace(/(\{|\s)/g, '');

for (var i = settings.excludeProperties.length - 1; i >= 0; i--) {
if (propertyName.indexOf(settings.excludeProperties[i]) === 0) {
Expand Down