Bladeren bron

always replace invalid href with empty URLs

Gildas 7 jaren geleden
bovenliggende
commit
076427efed
1 gewijzigde bestanden met toevoegingen van 4 en 14 verwijderingen
  1. 4 14
      lib/single-file/single-file-core.js

+ 4 - 14
lib/single-file/single-file-core.js

@@ -606,20 +606,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				const href = element.getAttribute("href");
 				if (!Util.testIgnoredPath(href) && Util.testValidPath(href, this.baseURI, this.options.url)) {
 					const normalizedHref = Util.normalizeURL(href);
-					if (element.tagName == "LINK") {
-						try {
-							element.setAttribute("href", DocUtil.resolveURL(href, this.options.baseURI || this.options.url));
-						} catch (error) {
-							if (element.tagName == "LINK") {
-								element.setAttribute("href", EMPTY_URL);
-							}
-						}
-					} else if (normalizedHref == href) {
-						try {
-							element.setAttribute("href", DocUtil.resolveURL(normalizedHref, this.options.baseURI || this.options.url));
-						} catch (error) {
-							// ignored
-						}
+					try {
+						element.setAttribute("href", DocUtil.resolveURL(normalizedHref == href ? normalizedHref : href, this.options.baseURI || this.options.url));
+					} catch (error) {
+						element.setAttribute("href", EMPTY_URL);
 					}
 				}
 			});