Преглед изворни кода

fixed font filtering issue

Gildas пре 7 година
родитељ
комит
70763a3fa0
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      lib/single-file/css-fonts-minifier.js

+ 3 - 3
lib/single-file/css-fonts-minifier.js

@@ -37,7 +37,7 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 	const REGEXP_FONT_FORMAT = /\.([^.?#]+)((\?|#).*?)?$/;
 	const REGEXP_FONT_FORMAT_VALUE = /format\((.*?)\)\s*,?$/;
 	const REGEXP_FONT_SRC = /(.*?)\s*,?$/;
-	const EMPTY_URL_SOURCE = "url(\"data:base64,\") format(\"woff\")";
+	const EMPTY_URL_SOURCE = "url(\"data:base64,\")";
 	const PSEUDO_ELEMENTS = ["::after", "::before", "::first-line", "::first-letter", ":before", ":after", ":first-line", ":first-letter", "::placeholder", "::selection", "::marker", "::cue", "::slotted", "::spelling-error", "::grammar-error"];
 	const FONT_WEIGHTS = {
 		normal: 400,
@@ -192,7 +192,7 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 		return stylesheetContent;
 	}
 
-	function processFontFaceRule(rule, fontInfo, stats) {		
+	function processFontFaceRule(rule, fontInfo, stats) {
 		let fontSources = fontInfo.map(fontSource => {
 			const fontFormatMatch = fontSource.match(REGEXP_FONT_FORMAT_VALUE);
 			let fontFormat;
@@ -224,7 +224,7 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 			}
 			return { src: fontSource.match(REGEXP_FONT_SRC)[1], format: fontFormat };
 		});
-		const fontTest = (fontSource, format) => fontSource.src != EMPTY_URL_SOURCE && fontSource.format == format;
+		const fontTest = (fontSource, format) => !fontSource.src.startsWith(EMPTY_URL_SOURCE) && fontSource.format == format;
 		let woffFontFound = fontSources.find(fontSource => fontTest(fontSource, "woff2-variations"));
 		if (!woffFontFound) {
 			woffFontFound = fontSources.find(fontSource => fontTest(fontSource, "woff2"));