Browse Source

test path validiity

Gildas 7 năm trước cách đây
mục cha
commit
7759edbd1b
1 tập tin đã thay đổi với 9 bổ sung7 xóa
  1. 9 7
      lib/single-file/single-file-core.js

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

@@ -581,13 +581,15 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				if (element.getAttribute("href")) {
 					const href = element.getAttribute("href");
 					if (href) {
-						const normalizedHref = DomUtil.normalizeURL(href);
-						if (element.tagName == "LINK" || normalizedHref == href) {
-							try {
-								element.setAttribute("href", new URL(href, this.options.baseURI || this.options.url));
-							} catch (error) {
-								if (element.tagName == "LINK") {
-									element.setAttribute("href", EMPTY_URL);
+						if (!DomUtil.testIgnoredPath(href) && DomUtil.testValidPath(href, this.baseURI, this.options.url)) {
+							const normalizedHref = DomUtil.normalizeURL(href);
+							if (element.tagName == "LINK" || normalizedHref == href) {
+								try {
+									element.setAttribute("href", new URL(href, this.options.baseURI || this.options.url));
+								} catch (error) {
+									if (element.tagName == "LINK") {
+										element.setAttribute("href", EMPTY_URL);
+									}
 								}
 							}
 						}