|
@@ -1074,17 +1074,23 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
|
|
|
|
|
static async processStylesheet(doc, stylesheetContent, cssRules, baseURI, options, batchRequest) {
|
|
static async processStylesheet(doc, stylesheetContent, cssRules, baseURI, options, batchRequest) {
|
|
|
const urlFunctions = getURLFunctions(cssRules);
|
|
const urlFunctions = getURLFunctions(cssRules);
|
|
|
- const styleResources = Promise.all(urlFunctions.style.map(urlFunction => processURLFunction(urlFunction, true)));
|
|
|
|
|
- const otherResources = Promise.all(urlFunctions.other.map(urlFunction => processURLFunction(urlFunction, false)));
|
|
|
|
|
|
|
+ const styleResources = Promise.all(urlFunctions.style.map(urlFunction => processURLFunction(urlFunction)));
|
|
|
|
|
+ const otherResources = Promise.all(urlFunctions.other.map(urlFunction => processURLFunction(urlFunction, true)));
|
|
|
await Promise.all([styleResources, otherResources]);
|
|
await Promise.all([styleResources, otherResources]);
|
|
|
return stylesheetContent;
|
|
return stylesheetContent;
|
|
|
|
|
|
|
|
- async function processURLFunction(urlFunction, groupDuplicates) {
|
|
|
|
|
|
|
+ async function processURLFunction(urlFunction, processFont) {
|
|
|
const originalResourceURL = DomUtil.matchURL(urlFunction);
|
|
const originalResourceURL = DomUtil.matchURL(urlFunction);
|
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
|
if (!DomUtil.testIgnoredPath(resourceURL)) {
|
|
if (!DomUtil.testIgnoredPath(resourceURL)) {
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
|
- const { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL);
|
|
|
|
|
|
|
+ let { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL);
|
|
|
|
|
+ if (processFont) {
|
|
|
|
|
+ const validFont = await DOM.validFont(content);
|
|
|
|
|
+ if (!validFont) {
|
|
|
|
|
+ content = EMPTY_DATA_URI;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
let regExpUrlFunction = DomUtil.getRegExp(urlFunction);
|
|
let regExpUrlFunction = DomUtil.getRegExp(urlFunction);
|
|
|
if (!stylesheetContent.match(regExpUrlFunction)) {
|
|
if (!stylesheetContent.match(regExpUrlFunction)) {
|
|
|
urlFunction = "url(" + originalResourceURL + ")";
|
|
urlFunction = "url(" + originalResourceURL + ")";
|
|
@@ -1095,7 +1101,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
regExpUrlFunction = DomUtil.getRegExp(urlFunction);
|
|
regExpUrlFunction = DomUtil.getRegExp(urlFunction);
|
|
|
}
|
|
}
|
|
|
if (stylesheetContent.match(regExpUrlFunction)) {
|
|
if (stylesheetContent.match(regExpUrlFunction)) {
|
|
|
- if (duplicate && options.groupDuplicateImages && groupDuplicates) {
|
|
|
|
|
|
|
+ if (duplicate && options.groupDuplicateImages && !processFont) {
|
|
|
stylesheetContent = stylesheetContent.replace(regExpUrlFunction, "var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")");
|
|
stylesheetContent = stylesheetContent.replace(regExpUrlFunction, "var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")");
|
|
|
DomUtil.insertVariable(doc, indexResource, content, options);
|
|
DomUtil.insertVariable(doc, indexResource, content, options);
|
|
|
} else {
|
|
} else {
|