/**
 * Mention
 */
import parseAcct from '../../../acct/parse';

module.exports = text => {
	const match = text.match(/^@[a-z0-9_]+(?:@[a-z0-9\.\-]+[a-z0-9])?/i);
	if (!match) return null;
	const mention = match[0];
	const { username, host } = parseAcct(mention.substr(1));
	return {
		type: 'mention',
		content: mention,
		username,
		host
	};
};
