1
0
forked from mirror/misskey
mi.moris.day/src/common/text/parse/elements/mention.ts
2018-04-02 04:15:27 +09:00

18 lines
347 B
TypeScript

/**
* Mention
*/
import parseAcct from '../../../../misc/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
};
};