Skip to content

Commit 8a9e731

Browse files
committed
extractWords ロジックを修正
1 parent db1f22e commit 8a9e731

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/server/src/extractor.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ const tokenizer = await new Promise<kuromoji.Tokenizer<kuromoji.IpadicFeatures>>
1212
const onlySpecialCharactersRegex = /^[\s!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]+$/;
1313
const onlyNumbersRegex = /^\d+$/;
1414
const urlRegex = /https?:\/\/\S+/g;
15+
const mentionRegex = /!\{"type":"(?:user|channel)","raw":"(.+)","id":"[a-z0-9\-]+"\}/g;
1516

1617
export const extractWords = async (text: string) => {
1718
const urlStripped = text.replace(urlRegex, '');
18-
const tokens = tokenizer.tokenize(urlStripped);
19+
const mentionsReplaced = urlStripped.replace(mentionRegex, (_, raw) => raw);
20+
const tokens = tokenizer.tokenize(mentionsReplaced);
1921

2022
const words = tokens
2123
.filter(

0 commit comments

Comments
 (0)