Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
[MM-36481] Fix thumbsup emoji parsing to support skin tones (#8318) (#…
Browse files Browse the repository at this point in the history
…8328)

* fix thumbsup emoji parsing

* fix tests

* fix help text

(cherry picked from commit 41b00f7)

Co-authored-by: Guillermo Vayá <[email protected]>
  • Loading branch information
mattermost-build and Willyfrog committed Jun 29, 2021
1 parent 70489df commit a4b6809
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"add_emoji.imageRequired": "An image is required for the emoji",
"add_emoji.imageTooLarge": "Unable to create emoji. Image must be less than 1 MB in size.",
"add_emoji.name": "Name",
"add_emoji.name.help": "Specify an emoji name that's up to 64 characters. It can contain lowercase letters, numbers, and the symbols '-' and '_'.",
"add_emoji.name.help": "Specify an emoji name that's up to 64 characters. It can contain lowercase letters, numbers, and the symbols '-', '+' and '_'.",
"add_emoji.nameInvalid": "An emoji's name can only contain lowercase letters, numbers, and the symbols '-' and '_'.",
"add_emoji.nameRequired": "A name is required for the emoji",
"add_emoji.nameTaken": "This name is already in use by a system emoji. Please choose another name.",
Expand Down
6 changes: 2 additions & 4 deletions utils/emoticons.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ describe('Emoticons', () => {
mask: [':-x'],
heart: ['<3', '&lt;3'],
broken_heart: ['</3', '&lt;/3'],
thumbsup: [':+1:'],
thumbsdown: [':-1:'],
};
Array.prototype.concat(...Object.values(emoticonPatterns)).forEach((emoticon) => {
test(`text sequence '${emoticon}' should be recognized as an emoticon`, () => {
Expand Down Expand Up @@ -117,7 +115,7 @@ describe('Emoticons', () => {
describe('multiple', () => {
test('shorthand forms', () => {
expect(Emoticons.matchEmoticons(':+1: :D')).
toEqual([':D', ':+1:']);
toEqual([':+1:', ':D']);
});

test('named emoticons forms', () => {
Expand All @@ -127,7 +125,7 @@ describe('Emoticons', () => {

test('mixed', () => {
expect(Emoticons.matchEmoticons(':thumbs_up: :smile: :+1: :D')).
toEqual([':thumbs_up:', ':smile:', ':D', ':+1:']);
toEqual([':thumbs_up:', ':smile:', ':+1:', ':D']);
});
});

Expand Down
4 changes: 1 addition & 3 deletions utils/emoticons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ export const emoticonPatterns: { [key: string]: RegExp } = {
mask: /(^|\B)(:-x)($|\b)/gi, // :-x
heart: /(^|\B)(<3|&lt;3)($|\b)/g, // <3
broken_heart: /(^|\B)(<\/3|&lt;\/3)($|\b)/g, // </3
thumbsup: /(^|\B)(:\+1:)($|\B)/g, // :+1:
thumbsdown: /(^|\B)(:-1:)($|\B)/g, // :-1:
};

export const EMOJI_PATTERN = /(:([a-zA-Z0-9_-]+):)/g;
export const EMOJI_PATTERN = /(:([a-zA-Z0-9_+-]+):)/g;

export function matchEmoticons(text: string): RegExpMatchArray | null {
let emojis = text.match(EMOJI_PATTERN);
Expand Down

0 comments on commit a4b6809

Please sign in to comment.