From f197a2aa39eb5cb77887b64b182be78a3eaefdd1 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 4 Jun 2020 15:12:03 +0200 Subject: [PATCH 1/3] EntityNormalizer: Add colons to emoji alt text. This makes it possible to copy them and still have them work. --- src/services/entity_normalizer/entity_normalizer.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 6dac7c15..c7ed65a4 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -210,7 +210,7 @@ export const addEmojis = (string, emojis) => { const regexSafeShortCode = emoji.shortcode.replace(matchOperatorsRegex, '\\$&') return acc.replace( new RegExp(`:${regexSafeShortCode}:`, 'g'), - `${emoji.shortcode}` + `:${emoji.shortcode}:` ) }, string) } From c2dfe1f6cc364175d5aa17d587f82bdb6b8b189c Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 4 Jun 2020 15:25:00 +0200 Subject: [PATCH 2/3] EntityNormalizerSpec: Test new behavior. --- .../services/entity_normalizer/entity_normalizer.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js index cfb380ba..178e75c6 100644 --- a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js +++ b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js @@ -338,9 +338,9 @@ describe('API Entities normalizer', () => { describe('MastoAPI emoji adder', () => { const emojis = makeMockEmojiMasto() - const imageHtml = 'image' + const imageHtml = ':image:' .replace(/"/g, '\'') - const thinkHtml = 'thinking' + const thinkHtml = ':thinking:' .replace(/"/g, '\'') it('correctly replaces shortcodes in supplied string', () => { From 05167f202fbb55d1cee1a1c36b630c18ab297419 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 4 Jun 2020 15:31:52 +0200 Subject: [PATCH 3/3] EntityNormalizerSpec: More fixes. --- .../services/entity_normalizer/entity_normalizer.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js index 178e75c6..166fce2b 100644 --- a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js +++ b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js @@ -366,8 +366,8 @@ describe('API Entities normalizer', () => { shortcode: '[a-z] {|}*' }]) const result = addEmojis('This post has :c++: emoji and :[a-z] {|}*: emoji', emojis) - expect(result).to.include('title=\'c++\'') - expect(result).to.include('title=\'[a-z] {|}*\'') + expect(result).to.include('title=\':c++:\'') + expect(result).to.include('title=\':[a-z] {|}*:\'') }) }) })