From 68cb0123a6bad3a39b7ec7b0029212790c0af83c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 20 Oct 2018 09:03:04 +0900 Subject: [PATCH] Fix #2949 --- src/mfm/parse/elements/hashtag.ts | 4 ++-- test/mfm.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mfm/parse/elements/hashtag.ts b/src/mfm/parse/elements/hashtag.ts index 339026228..e4e9df6ce 100644 --- a/src/mfm/parse/elements/hashtag.ts +++ b/src/mfm/parse/elements/hashtag.ts @@ -9,9 +9,9 @@ export type TextElementHashtag = { }; export default function(text: string, i: number) { - if (!(/^\s#[^\s\.,]+/.test(text) || (i == 0 && /^#[^\s\.,]+/.test(text)))) return null; + if (!(/^\s#[^\s\.,!\?]+/.test(text) || (i == 0 && /^#[^\s\.,!\?]+/.test(text)))) return null; const isHead = text.startsWith('#'); - const hashtag = text.match(/^\s?#[^\s\.,]+/)[0]; + const hashtag = text.match(/^\s?#[^\s\.,!\?]+/)[0]; const res: any[] = !isHead ? [{ type: 'text', content: text[0] diff --git a/test/mfm.ts b/test/mfm.ts index ad12eac7b..684cf42fb 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -122,6 +122,11 @@ describe('Text', () => { { type: 'hashtag', content: '#piyo', hashtag: 'piyo' }, { type: 'text', content: '.' } ], tokens2); + + const tokens3 = analyze('#Foo!'); + assert.deepEqual([ + { type: 'text', content: '#Foo!' }, + ], tokens3); }); it('quote', () => {