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

15 lines
233 B
TypeScript
Raw Normal View History

2016-12-28 22:49:51 +00:00
/**
* Mention
*/
2017-02-10 17:32:00 +00: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-28 22:49:51 +00:00
};