Fix username/mention regexes
* Allow underscore instead of hypen * Fix domain part handling * Add tests for remote mention
This commit is contained in:
parent
34281de04e
commit
3c4235067f
6 changed files with 17 additions and 7 deletions
14
test/text.ts
14
test/text.ts
|
@ -9,9 +9,11 @@ const syntaxhighlighter = require('../built/text/parse/core/syntax-highlighter')
|
|||
|
||||
describe('Text', () => {
|
||||
it('can be analyzed', () => {
|
||||
const tokens = analyze('@himawari お腹ペコい :cat: #yryr');
|
||||
const tokens = analyze('@himawari @hima_sub@namori.net お腹ペコい :cat: #yryr');
|
||||
assert.deepEqual([
|
||||
{ type: 'mention', content: '@himawari', username: 'himawari', host: null },
|
||||
{ type: 'text', content: ' '},
|
||||
{ type: 'mention', content: '@hima_sub@namori.net', username: 'hima_sub', host: 'namori.net' },
|
||||
{ type: 'text', content: ' お腹ペコい ' },
|
||||
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
|
||||
{ type: 'text', content: ' '},
|
||||
|
@ -20,7 +22,7 @@ describe('Text', () => {
|
|||
});
|
||||
|
||||
it('can be inverted', () => {
|
||||
const text = '@himawari お腹ペコい :cat: #yryr';
|
||||
const text = '@himawari @hima_sub@namori.net お腹ペコい :cat: #yryr';
|
||||
assert.equal(analyze(text).map(x => x.content).join(''), text);
|
||||
});
|
||||
|
||||
|
@ -41,6 +43,14 @@ describe('Text', () => {
|
|||
], tokens);
|
||||
});
|
||||
|
||||
it('remote mention', () => {
|
||||
const tokens = analyze('@hima_sub@namori.net お腹ペコい');
|
||||
assert.deepEqual([
|
||||
{ type: 'mention', content: '@hima_sub@namori.net', username: 'hima_sub', host: 'namori.net' },
|
||||
{ type: 'text', content: ' お腹ペコい' }
|
||||
], tokens);
|
||||
});
|
||||
|
||||
it('hashtag', () => {
|
||||
const tokens = analyze('Strawberry Pasta #alice');
|
||||
assert.deepEqual([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue