summaryrefslogtreecommitdiff
path: root/src/mfm/parse/elements/mention.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-11-21 05:11:00 +0900
committerGitHub <noreply@github.com>2018-11-21 05:11:00 +0900
commit79ffbf95db9d0cc019d06ab93b1bfa6ba0d4f9ae (patch)
tree884a18e6735f8557eb392929fcfa2dc1ae09cb6d /src/mfm/parse/elements/mention.ts
parentRefactor checkMongoDb (#3339) (diff)
downloadmisskey-79ffbf95db9d0cc019d06ab93b1bfa6ba0d4f9ae.tar.gz
misskey-79ffbf95db9d0cc019d06ab93b1bfa6ba0d4f9ae.tar.bz2
misskey-79ffbf95db9d0cc019d06ab93b1bfa6ba0d4f9ae.zip
Improve MFM parser (#3337)
* wip * wip * Refactor * Refactor * wip * wip * wip * wip * Refactor * Refactor * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Clean up * Update misskey-flavored-markdown.ts * wip * wip * wip * wip * Update parser.ts * wip * Add new test * wip * Add new test * Add new test * wip * Refactor * Update parse.ts * Refactor * Update parser.ts * wip
Diffstat (limited to 'src/mfm/parse/elements/mention.ts')
-rw-r--r--src/mfm/parse/elements/mention.ts29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/mfm/parse/elements/mention.ts b/src/mfm/parse/elements/mention.ts
deleted file mode 100644
index 7a609e5d34..0000000000
--- a/src/mfm/parse/elements/mention.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Mention
- */
-import parseAcct from '../../../misc/acct/parse';
-import { toUnicode } from 'punycode';
-
-export type TextElementMention = {
- type: 'mention';
- content: string;
- canonical: string;
- username: string;
- host: string;
-};
-
-export default function(text: string, before: string) {
- const match = text.match(/^@[a-z0-9_]+(?:@[a-z0-9\.\-]+[a-z0-9])?/i);
- if (!match) return null;
- if (/[a-zA-Z0-9]$/.test(before)) return null;
- const mention = match[0];
- const { username, host } = parseAcct(mention.substr(1));
- const canonical = host != null ? `@${username}@${toUnicode(host)}` : mention;
- return {
- type: 'mention',
- content: mention,
- canonical,
- username,
- host
- } as TextElementMention;
-}