diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-20 09:03:04 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-20 09:03:04 +0900 |
| commit | 70d0937aab71de6e9fb475e01940bebde3b6d77d (patch) | |
| tree | 9ef85da0fd95be458111c0f0a2c6345a47264566 | |
| parent | 10.27.0 (diff) | |
| download | sharkey-70d0937aab71de6e9fb475e01940bebde3b6d77d.tar.gz sharkey-70d0937aab71de6e9fb475e01940bebde3b6d77d.tar.bz2 sharkey-70d0937aab71de6e9fb475e01940bebde3b6d77d.zip | |
Fix #2949
| -rw-r--r-- | src/mfm/parse/elements/hashtag.ts | 4 | ||||
| -rw-r--r-- | 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 339026228a..e4e9df6ce3 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 ad12eac7b7..684cf42fbc 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', () => { |