Skip to content

Commit

Permalink
.付きのusernameを認識できるように
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Mar 23, 2024
1 parent 11ab686 commit ecc6e21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/app/common/views/directives/autocomplete.ts
Expand Up @@ -107,7 +107,7 @@ class Autocomplete {

if (isMention) {
const username = text.substr(mentionIndex + 1);
if (username.match(/^[\w-]+$/)) {
if (username.match(/^[\w.-]+$/)) {
this.open('user', username.toLowerCase());
opened = true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/mfm/language.ts
Expand Up @@ -262,8 +262,7 @@ export const mfmLanguage = P.createLanguage({
mention: () => {
return P((input, i) => {
const text = input.substr(i);
// eslint-disable-next-line no-useless-escape
const match = text.match(/^@\w([\w-]*\w)?(?:@[\w\.\-]+\w)?/);
const match = text.match(/^@([\w.-]+)(?:@[\w.-]+\w)?/);
if (!match) return P.makeFailure(i, 'not a mention');
// @ の前に何かあればハッシュタグ扱いしない
if (input[i - 1]?.match(/[^\s\u200b]/)) return P.makeFailure(i, 'not a mention');
Expand Down
13 changes: 13 additions & 0 deletions test/mfm.ts
Expand Up @@ -427,6 +427,19 @@ describe('parse', () => {
]);
});

it('remote with dot', () => {
const tokens = parseFull('@hima.sub@namori.net foo');
assert.deepStrictEqual(tokens, [
leaf('mention', {
acct: '@hima.sub@namori.net',
canonical: '@hima.sub@namori.net',
username: 'hima.sub',
host: 'namori.net'
}),
text(' foo')
]);
});

it('ignore', () => {
const tokens = parseFull('idolm@ster');
assert.deepStrictEqual(tokens, [
Expand Down

0 comments on commit ecc6e21

Please sign in to comment.