Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support . in mentions #150

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Improvements

### Changes
- allow `.` in mentions (like `@[email protected]`)

### Bugfixes

Expand Down
2 changes: 1 addition & 1 deletion src/internal/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// tsdのテストでファイルを追加しているにも関わらず「@twemoji/parser/dist/lib/regex」の型定義ファイルがないとエラーが出るため、
// このエラーを無視する。
/* eslint @typescript-eslint/ban-ts-comment: 1 */
// @ts-ignore

Check warning on line 10 in src/internal/parser.ts

View workflow job for this annotation

GitHub Actions / lint

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
import twemojiRegex from '@twemoji/parser/dist/lib/regex';

type ArgPair = { k: string, v: string | true };
Expand Down Expand Up @@ -552,7 +552,7 @@
const parser = P.seq(
notLinkLabel,
P.str('@'),
P.regexp(/[a-z0-9_-]+/i),
P.regexp(/[a-z0-9_.-]+/i),
P.seq(
P.str('@'),
P.regexp(/[a-z0-9_.-]+/i),
Expand Down
6 changes: 6 additions & 0 deletions test/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,12 @@ hoge`;
assert.deepStrictEqual(mfm.parse(input), output);
});

test('allow "." in username', () => {
const input = '@[email protected]';
const output = [MENTION('bsky.brid.gy', 'bsky.brid.gy', '@[email protected]')];
assert.deepStrictEqual(mfm.parse(input), output);
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test('disallow "." in tail of username'とかも必要かもです

test('disallow "-" in head of username', () => {
const input = '@-abc';
const output = [TEXT('@-abc')];
Expand Down
Loading