mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-19 08:27:35 -07:00
18 lines
305 B
JavaScript
18 lines
305 B
JavaScript
|
/**
|
||
|
* 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)
|
||
|
};
|
||
|
}
|
||
|
};
|