Răsfoiți Sursa

minor refactoring

Gildas 7 ani în urmă
părinte
comite
21c070a9a7
1 a modificat fișierele cu 8 adăugiri și 2 ștergeri
  1. 8 2
      lib/single-file/single-file-core.js

+ 8 - 2
lib/single-file/single-file-core.js

@@ -579,9 +579,9 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		resolveHrefs() {
 			this.doc.querySelectorAll("[href]").forEach(element => {
 				const href = element.getAttribute("href");
-				if (href && !DomUtil.testIgnoredPath(href) && DomUtil.testValidPath(href, this.baseURI, this.options.url)) {
+				if (!DomUtil.testIgnoredPath(href) && DomUtil.testValidPath(href, this.baseURI, this.options.url)) {
 					const normalizedHref = DomUtil.normalizeURL(href);
-					if (element.tagName == "LINK" || normalizedHref == href) {
+					if (element.tagName == "LINK") {
 						try {
 							element.setAttribute("href", new URL(href, this.options.baseURI || this.options.url));
 						} catch (error) {
@@ -589,6 +589,12 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 								element.setAttribute("href", EMPTY_URL);
 							}
 						}
+					} else if (normalizedHref == href) {
+						try {
+							element.setAttribute("href", new URL(normalizedHref, this.options.baseURI || this.options.url));
+						} catch (error) {
+							// ignored
+						}
 					}
 				}
 			});