1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

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.
This commit is contained in:
Michał Laskowski 2015-11-13 14:16:53 +01:00
parent 4188d2f75b
commit b465485e10

View file

@ -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) {