From ecc6e21f7bbc73f391fc26d1bc465727382b3797 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 23 Mar 2024 22:11:55 +0900 Subject: [PATCH] =?UTF-8?q?.=E4=BB=98=E3=81=8D=E3=81=AEusername=E3=82=92?= =?UTF-8?q?=E8=AA=8D=E8=AD=98=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/common/views/directives/autocomplete.ts | 2 +- src/mfm/language.ts | 3 +-- test/mfm.ts | 13 +++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/client/app/common/views/directives/autocomplete.ts b/src/client/app/common/views/directives/autocomplete.ts index 3c8e1eba0a98..c1e3dee932cb 100644 --- a/src/client/app/common/views/directives/autocomplete.ts +++ b/src/client/app/common/views/directives/autocomplete.ts @@ -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; } diff --git a/src/mfm/language.ts b/src/mfm/language.ts index 4c29e50beefe..4ea20a68ef73 100644 --- a/src/mfm/language.ts +++ b/src/mfm/language.ts @@ -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'); diff --git a/test/mfm.ts b/test/mfm.ts index 23ef3197bf8f..51df15e020aa 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -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, [