Skip to content

Commit 5d2098f

Browse files
authored
Merge pull request #134 from takker99/cut-line-id
🐛 Didn't identify [A#xxxx...] as [A] wrongly
2 parents 8a6df46 + 1e86c72 commit 5d2098f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

browser/websocket/makeChanges.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,20 @@ const findLinksAndImage = (
9898
return;
9999
case "link":
100100
switch (node.pathType) {
101-
case "relative":
102-
if (linksLc.get(toTitleLc(node.href))) return;
103-
linksLc.set(toTitleLc(node.href), true);
104-
links.push(node.href);
101+
case "relative": {
102+
const link = cutId(node.href);
103+
if (linksLc.get(toTitleLc(link))) return;
104+
linksLc.set(toTitleLc(link), true);
105+
links.push(link);
105106
return;
106-
case "root":
107-
if (projectLinksLc.has(toTitleLc(node.href))) return;
108-
projectLinksLc.add(toTitleLc(node.href));
109-
projectLinks.push(node.href);
107+
}
108+
case "root": {
109+
const link = cutId(node.href);
110+
if (projectLinksLc.has(toTitleLc(link))) return;
111+
projectLinksLc.add(toTitleLc(link));
112+
projectLinks.push(link);
110113
return;
114+
}
111115
case "absolute": {
112116
const props = parseYoutube(node.href);
113117
if (!props || props.pathType === "list") return;
@@ -167,3 +171,5 @@ function* blocksToNodes(blocks: Iterable<Block>) {
167171
}
168172
}
169173
}
174+
175+
const cutId = (link: string): string => link.replace(/#[a-f\d]{24,32}$/, "");

0 commit comments

Comments
 (0)