|
|
@@ -1169,20 +1169,16 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (DomUtil.testValidPath(resourceURL)) {
|
|
|
resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI)) {
|
|
|
- try {
|
|
|
- const { content } = await batchRequest.addURL(resourceURL);
|
|
|
- if (!content.startsWith(prefixDataURI) && !content.startsWith(PREFIX_DATA_URI_NO_MIMETYPE) && !content.startsWith(PREFIX_DATA_URI_OCTET_STREAM)) {
|
|
|
- resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
|
|
|
- }
|
|
|
- return content + (srcsetValue.w ? " " + srcsetValue.w + "w" : srcsetValue.d ? " " + srcsetValue.d + "x" : "");
|
|
|
- } catch (error) {
|
|
|
+ const { content } = await batchRequest.addURL(resourceURL);
|
|
|
+ if (!content.startsWith(prefixDataURI) && !content.startsWith(PREFIX_DATA_URI_NO_MIMETYPE) && !content.startsWith(PREFIX_DATA_URI_OCTET_STREAM)) {
|
|
|
resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
|
|
|
}
|
|
|
+ return content + (srcsetValue.w ? " " + srcsetValue.w + "w" : srcsetValue.d ? " " + srcsetValue.d + "x" : "");
|
|
|
} else {
|
|
|
- resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
|
|
|
+ return "";
|
|
|
}
|
|
|
} else {
|
|
|
- resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
|
|
|
+ return "";
|
|
|
}
|
|
|
}
|
|
|
}));
|
|
|
@@ -1198,9 +1194,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const DATA_URI_PREFIX = "data:";
|
|
|
const BLOB_URI_PREFIX = "blob:";
|
|
|
const HTTP_URI_PREFIX = /^https?:\/\//;
|
|
|
+ const FILE_URI_PREFIX = /^file:\/\//;
|
|
|
const EMPTY_URL = /^https?:\/\/+\s*$/;
|
|
|
const ABOUT_BLANK_URI = "about:blank";
|
|
|
- const NOT_EMPTY_URL = /^https?:\/\/.+/;
|
|
|
+ const NOT_EMPTY_URL = /^(https|file)?:\/\/.+/;
|
|
|
const REGEXP_URL_FN = /(url\s*\(\s*'(.*?)'\s*\))|(url\s*\(\s*"(.*?)"\s*\))|(url\s*\(\s*(.*?)\s*\))/gi;
|
|
|
const REGEXP_URL_SIMPLE_QUOTES_FN = /^url\s*\(\s*'(.*?)'\s*\)$/i;
|
|
|
const REGEXP_URL_DOUBLE_QUOTES_FN = /^url\s*\(\s*"(.*?)"\s*\)$/i;
|
|
|
@@ -1280,7 +1277,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
}
|
|
|
|
|
|
static testValidURL(resourceURL, baseURI) {
|
|
|
- return DomUtil.testValidPath(resourceURL, baseURI) && resourceURL.match(HTTP_URI_PREFIX) && resourceURL.match(NOT_EMPTY_URL);
|
|
|
+ return DomUtil.testValidPath(resourceURL, baseURI) && (resourceURL.match(HTTP_URI_PREFIX) || resourceURL.match(FILE_URI_PREFIX)) && resourceURL.match(NOT_EMPTY_URL);
|
|
|
}
|
|
|
|
|
|
static matchImport(stylesheetContent) {
|