1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-05 17:05:55 +02:00
Files
misskey/src/common/text/elements/mention.ts
2018-03-29 20:32:18 +09:00

18 lines
346 B
TypeScript

/**
* Mention
*/
import parseAcct from '../../../common/user/parse-acct';
module.exports = text => {
const match = text.match(/^(?:@[a-zA-Z0-9\-]+){1,2}/);
if (!match) return null;
const mention = match[0];
const { username, host } = parseAcct(mention.substr(1));
return {
type: 'mention',
content: mention,
username,
host
};
};