Sharkey/src/api/common/text/elements/mention.ts

15 lines
233 B
TypeScript
Raw Normal View History

2016-12-29 07:49:51 +09:00
/**
* Mention
*/
2017-02-11 02:32:00 +09:00
module.exports = text => {
const match = text.match(/^@[a-zA-Z0-9\-]+/);
if (!match) return null;
const mention = match[0];
return {
type: 'mention',
content: mention,
username: mention.substr(1)
};
2016-12-29 07:49:51 +09:00
};