Prechádzať zdrojové kódy

catch errors when parsing URL

Gildas 7 rokov pred
rodič
commit
03d0ef8d0c
1 zmenil súbory, kde vykonal 7 pridanie a 1 odobranie
  1. 7 1
      lib/single-file/single-file-core.js

+ 7 - 1
lib/single-file/single-file-core.js

@@ -583,7 +583,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 					if (href) {
 						const normalizedHref = DomUtil.normalizeURL(href);
 						if (element.tagName == "LINK" || normalizedHref == href) {
-							element.setAttribute("href", new URL(href, this.options.baseURI || this.options.url));
+							try {
+								element.setAttribute("href", new URL(href, this.options.baseURI || this.options.url));
+							} catch (error) {
+								if (element.tagName == "LINK") {
+									element.setAttribute("href", EMPTY_URL);
+								}
+							}
 						}
 					}
 				}