Sfoglia il codice sorgente

resolve a and link hrefs only

Gildas 7 anni fa
parent
commit
f05e233ee3
1 ha cambiato i file con 5 aggiunte e 6 eliminazioni
  1. 5 6
      lib/single-file/single-file-core.js

+ 5 - 6
lib/single-file/single-file-core.js

@@ -602,14 +602,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		}
 
 		resolveHrefs() {
-			this.doc.querySelectorAll("[href]").forEach(element => {
-				const href = element.getAttribute("href");
-				if (!Util.testIgnoredPath(href) && Util.testValidPath(href, this.baseURI, this.options.url)) {
-					const normalizedHref = Util.normalizeURL(href);
+			this.doc.querySelectorAll("a[href], link[href]").forEach(element => {
+				const href = element.getAttribute("href").trim();
+				if (!Util.testIgnoredPath(href) && !href.startsWith("#")) {
 					try {
-						element.setAttribute("href", DocUtil.resolveURL(normalizedHref == href ? normalizedHref : href, this.options.baseURI || this.options.url));
+						element.setAttribute("href", DocUtil.resolveURL(href, this.options.baseURI || this.options.url));
 					} catch (error) {
-						element.setAttribute("href", EMPTY_URL);
+						// ignored
 					}
 				}
 			});