1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-07-28 04:04:37 +02:00
Files
misskey/src/text/parse/elements/mention.ts
unarist 3c4235067f Fix username/mention regexes
* Allow underscore instead of hypen
* Fix domain part handling
* Add tests for remote mention
2018-04-09 01:52:41 +09:00

18 lines
349 B
TypeScript

/**
* 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
};
};