瀏覽代碼

catch errors when parsing URL

Gildas 7 年之前
父節點
當前提交
03d0ef8d0c
共有 1 個文件被更改,包括 7 次插入1 次删除
  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);
+								}
+							}
 						}
 					}
 				}