|
|
@@ -1149,7 +1149,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (match) {
|
|
|
let resourceURL = DomUtil.normalizeURL(match.resourceURL);
|
|
|
if (!DomUtil.testIgnoredPath(resourceURL) && DomUtil.testValidPath(resourceURL, baseURI, options.url)) {
|
|
|
- resourceURL = new URL(match.resourceURL, baseURI).href;
|
|
|
+ try {
|
|
|
+ resourceURL = new URL(match.resourceURL, baseURI).href;
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
|
const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, validateTextContentType: true };
|
|
|
let importedStylesheetContent = await Download.getContent(resourceURL, downloadOptions);
|
|
|
@@ -1176,7 +1180,12 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
|
if (!DomUtil.testIgnoredPath(resourceURL)) {
|
|
|
if (DomUtil.testValidPath(resourceURL, baseURI, options.url)) {
|
|
|
- const resolvedURL = new URL(resourceURL, baseURI).href;
|
|
|
+ let resolvedURL;
|
|
|
+ try {
|
|
|
+ resolvedURL = new URL(resourceURL, baseURI).href;
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
if (DomUtil.testValidURL(resolvedURL, baseURI, options.url) && resourceURL != resolvedURL && stylesheetContent.includes(urlFunction)) {
|
|
|
stylesheetContent = stylesheetContent.replace(DomUtil.getRegExp(urlFunction), urlFunction.replace(originalResourceURL, resolvedURL));
|
|
|
}
|
|
|
@@ -1298,7 +1307,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (!DomUtil.testIgnoredPath(resourceURL)) {
|
|
|
resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
|
|
|
if (DomUtil.testValidPath(resourceURL, baseURI, options.url)) {
|
|
|
- resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
+ try {
|
|
|
+ resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
|
const { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL);
|
|
|
if (removeElementIfMissing && content == EMPTY_DATA_URI) {
|
|
|
@@ -1332,7 +1345,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
let resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
|
if (DomUtil.testValidPath(resourceURL, baseURI, options.url) && !DomUtil.testIgnoredPath(resourceURL)) {
|
|
|
resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
|
|
|
- resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
+ try {
|
|
|
+ resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
|
try {
|
|
|
const { content } = await batchRequest.addURL(resourceURL, false);
|
|
|
@@ -1369,7 +1386,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
let resourceURL = DomUtil.normalizeURL(srcsetValue.url);
|
|
|
if (!DomUtil.testIgnoredPath(resourceURL)) {
|
|
|
if (DomUtil.testValidPath(resourceURL, baseURI, options.url)) {
|
|
|
- resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
+ try {
|
|
|
+ resourceURL = new URL(resourceURL, baseURI).href;
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
|
const { content } = await batchRequest.addURL(resourceURL);
|
|
|
if (!content.startsWith(prefixDataURI) && !content.startsWith(PREFIX_DATA_URI_NO_MIMETYPE) && !content.match(PREFIX_DATA_URI_OCTET_STREAM)) {
|