Remove \uFE0F emoji variant from emoji name map

This commit is contained in:
Pavel Djundik 2019-10-03 13:35:38 +03:00
parent 12cdf280fc
commit 10b1cedbb6
3 changed files with 22 additions and 2 deletions

View File

@ -12,7 +12,7 @@ import LinkPreviewFileSize from "../../components/LinkPreviewFileSize.vue";
import InlineChannel from "../../components/InlineChannel.vue";
import Username from "../../components/Username.vue";
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]/gu;
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]|\u{fe0f}/gu;
// Create an HTML `span` with styling information for a given fragment
function createFragment(fragment, createElement) {

View File

@ -4,6 +4,9 @@ const got = require("got");
const path = require("path");
const fs = require("fs");
// same regex as found in client/../parse.js
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]|\u{fe0f}/gu;
(async () => {
const response = await got(
"https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json"
@ -13,7 +16,8 @@ const fs = require("fs");
const fullNameEmojiMap = {};
for (const emoji of emojiStrategy) {
fullNameEmojiMap[emoji.emoji] = emoji.description;
const cleanEmoji = emoji.emoji.replace(emojiModifiersRegex, "");
fullNameEmojiMap[cleanEmoji] = emoji.description;
for (const alias of emoji.aliases) {
emojiMap[alias] = emoji.emoji;

View File

@ -458,6 +458,22 @@ describe("IRC formatted message parser", () => {
expected:
'<span role="img" aria-label="Emoji: woman shrugging" title="Emoji: woman shrugging" class="emoji">🤷‍♀️</span>',
},
{
name: "with emoji variant selector",
input: "\u{2695}\u{FE0F}",
expected:
'<span role="img" aria-label="Emoji: medical symbol" title="Emoji: medical symbol" class="emoji">\u{2695}\u{FE0F}</span>',
},
{
name: "with text variant selector",
input: "\u{2695}\u{FE0E}",
expected: "\u{2695}\u{FE0E}", // this does not match because FE0E is specifically a text variant
},
{
name: "without variant selector",
input: "\u{2695}",
expected: "\u{2695}", // this does not match because emoji-regex expects \uFE0F as per the emoji specification
},
{
// FIXME: These multiple `span`s should be optimized into a single one. See https://github.com/thelounge/thelounge/issues/1783
name: "wrapped in style",