jormungandr-bite/src/common/text/elements/mention.js

18 lines
305 B
JavaScript
Raw Normal View History

2016-12-28 15:49:51 -07:00
/**
* Mention
*/
const regexp = /@[a-zA-Z0-9\-]+/;
module.exports = {
test: x => new RegExp('^' + regexp.source).test(x),
parse: text => {
const mention = text.match(new RegExp('^' + regexp.source))[0];
return {
type: 'mention',
content: mention,
username: mention.substr(1)
};
}
};