Explorar o código

catch errors when parsing URL

Gildas %!s(int64=7) %!d(string=hai) anos
pai
achega
03d0ef8d0c
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  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);
+								}
+							}
 						}
 					}
 				}