From 600aea4dbb76e9fd6280aa992e5d6b77c05d24c5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 3 Nov 2018 22:35:24 +0900 Subject: [PATCH] [MFM] Fix emoji syntax parsing --- src/mfm/parse/elements/emoji.ts | 2 +- test/mfm.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mfm/parse/elements/emoji.ts b/src/mfm/parse/elements/emoji.ts index cd9a3d032c..e510b5d912 100644 --- a/src/mfm/parse/elements/emoji.ts +++ b/src/mfm/parse/elements/emoji.ts @@ -9,7 +9,7 @@ export type TextElementEmoji = { }; export default function(text: string) { - const match = text.match(/^:([a-zA-Z0-9+-_]+):/); + const match = text.match(/^:([a-zA-Z0-9+-_]+?):/); if (!match) return null; const emoji = match[0]; return { diff --git a/test/mfm.ts b/test/mfm.ts index f5e5223f29..1aadcd21e8 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -180,10 +180,17 @@ describe('Text', () => { }); it('emoji', () => { - const tokens = analyze(':cat:'); + const tokens1 = analyze(':cat:'); assert.deepEqual([ { type: 'emoji', content: ':cat:', emoji: 'cat'} - ], tokens); + ], tokens1); + + const tokens2 = analyze(':cat::cat::cat:'); + assert.deepEqual([ + { type: 'emoji', content: ':cat:', emoji: 'cat'}, + { type: 'emoji', content: ':cat:', emoji: 'cat'}, + { type: 'emoji', content: ':cat:', emoji: 'cat'} + ], tokens2); }); it('block code', () => {