From 1e86c72a171bd570aa7d06f27c7e0174c6a87bf0 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Sun, 30 Jul 2023 17:32:51 +0900 Subject: [PATCH] :bug: Didn't identify [A#xxxx...] as [A] wrongly --- browser/websocket/makeChanges.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/browser/websocket/makeChanges.ts b/browser/websocket/makeChanges.ts index 79b762b..6894ae6 100644 --- a/browser/websocket/makeChanges.ts +++ b/browser/websocket/makeChanges.ts @@ -98,16 +98,20 @@ const findLinksAndImage = ( return; case "link": switch (node.pathType) { - case "relative": - if (linksLc.get(toTitleLc(node.href))) return; - linksLc.set(toTitleLc(node.href), true); - links.push(node.href); + case "relative": { + const link = cutId(node.href); + if (linksLc.get(toTitleLc(link))) return; + linksLc.set(toTitleLc(link), true); + links.push(link); return; - case "root": - if (projectLinksLc.has(toTitleLc(node.href))) return; - projectLinksLc.add(toTitleLc(node.href)); - projectLinks.push(node.href); + } + case "root": { + const link = cutId(node.href); + if (projectLinksLc.has(toTitleLc(link))) return; + projectLinksLc.add(toTitleLc(link)); + projectLinks.push(link); return; + } case "absolute": { const props = parseYoutube(node.href); if (!props || props.pathType === "list") return; @@ -167,3 +171,5 @@ function* blocksToNodes(blocks: Iterable) { } } } + +const cutId = (link: string): string => link.replace(/#[a-f\d]{24,32}$/, "");