فهرست منبع

fixed URL resolving when saving in background

Gildas 7 سال پیش
والد
کامیت
8753974850
1فایلهای تغییر یافته به همراه7 افزوده شده و 5 حذف شده
  1. 7 5
      lib/single-file/single-file-core.js

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

@@ -578,11 +578,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 		resolveHrefs() {
 			this.doc.querySelectorAll("[href]").forEach(element => {
-				if (element.href) {
-					const href = element.href.baseVal ? element.href.baseVal : element.href;
-					const normalizedHref = DomUtil.normalizeURL(href);
-					if (normalizedHref == href && href) {
-						element.setAttribute("href", href);
+				if (element.getAttribute("href")) {
+					const href = element.getAttribute("href");
+					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));
+						}
 					}
 				}
 			});