From b465485e102b03f0d4d0028c1fe6f7fdba807df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Laskowski?= Date: Fri, 13 Nov 2015 14:16:53 +0100 Subject: [PATCH] Don't replace url in stylesheets when url is data uri. Remove query part from the url path, when try to find the file in the archive during replacing urls in the stylesheets. --- src/replace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/replace.js b/src/replace.js index 1e96226..6151433 100644 --- a/src/replace.js +++ b/src/replace.js @@ -130,7 +130,7 @@ EPUBJS.replace.stylesheets = function(_store, full) { EPUBJS.replace.cssUrls = function(_store, base, text){ var deferred = new RSVP.defer(), promises = [], - matches = text.match(/url\(\'?\"?([^\'|^\"^\)]*)\'?\"?\)/g); + matches = text.match(/url\(\'?\"?((?!data:)[^\'|^\"^\)]*)\'?\"?\)/g); if(!_store) return; @@ -140,7 +140,7 @@ EPUBJS.replace.cssUrls = function(_store, base, text){ } matches.forEach(function(str){ - var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]/g, '')); + var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]|\?.*$/g, '')); var replaced = _store.getUrl(full).then(function(url){ text = text.replace(str, 'url("'+url+'")'); }, function(reason) {