Procházet zdrojové kódy

remove anchor whne saving links

Gildas před 3 měsíci
rodič
revize
b694321c07
1 změnil soubory, kde provedl 7 přidání a 3 odebrání
  1. 7 3
      src/ui/content/content-ui.js

+ 7 - 3
src/ui/content/content-ui.js

@@ -21,7 +21,7 @@
  *   Source.
  */
 
-/* global browser, document, prompt, getComputedStyle, addEventListener, removeEventListener, requestAnimationFrame, setTimeout, getSelection, Node */
+/* global browser, document, prompt, getComputedStyle, addEventListener, removeEventListener, requestAnimationFrame, setTimeout, getSelection, Node, URL */
 
 const singlefile = globalThis.singlefile;
 
@@ -172,7 +172,9 @@ function getSelectedLinks() {
 					if (range.startContainer != range.endContainer || range.startOffset != range.endOffset) {
 						selectionFound = true;
 						if (treeWalker.currentNode.tagName == "A" && treeWalker.currentNode.href) {
-							links.push(treeWalker.currentNode.href);
+							const url = new URL(treeWalker.currentNode.href);
+							url.hash = "";
+							links.push(url.href);
 						}
 					}
 				}
@@ -185,7 +187,9 @@ function getSelectedLinks() {
 			if (selectionFound && treeWalker.currentNode == range.endContainer && treeWalker.currentNode.querySelectorAll) {
 				treeWalker.currentNode.querySelectorAll("*").forEach(descendantElement => {
 					if (descendantElement.tagName == "A" && descendantElement.href) {
-						links.push(treeWalker.currentNode.href);
+						const url = new URL(descendantElement.href);
+						url.hash = "";
+						links.push(url.href);
 					}
 				});
 			}