mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-18 12:46:58 -06:00
Keep keycap emojis intact when stripping invisible characters
This commit is contained in:
@@ -115,10 +115,17 @@ describe("actuallyNonEmptyStringOrNull", () => {
|
||||
});
|
||||
|
||||
test.each([
|
||||
{ why: "rainbow flag", value: "she/her \ud83c\udff3\ufe0f\u200d\ud83c\udf08" },
|
||||
{
|
||||
why: "rainbow flag",
|
||||
value: "she/her \ud83c\udff3\ufe0f\u200d\ud83c\udf08",
|
||||
},
|
||||
{ why: "transgender flag", value: "\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f" },
|
||||
{ why: "family", value: "\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67" },
|
||||
{
|
||||
why: "family",
|
||||
value: "\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67",
|
||||
},
|
||||
{ why: "emoji presentation heart", value: "GG \u2764\ufe0f" },
|
||||
{ why: "keycap", value: "1\ufe0f\u20e3 2\ufe0f\u20e3 #\ufe0f\u20e3" },
|
||||
])("keeps the joiners and selectors of an emoji ($why)", ({ value }) => {
|
||||
expect(actuallyNonEmptyStringOrNull(value)).toBe(value);
|
||||
});
|
||||
|
||||
@@ -440,8 +440,9 @@ const EMPTY_CHARACTERS = [
|
||||
];
|
||||
const EMOJI_PART = "\\p{Extended_Pictographic}(?:\\uFE0F|\\p{Emoji_Modifier})?";
|
||||
const EMOJI_SEQUENCE = `${EMOJI_PART}(?:\\u200D${EMOJI_PART})*`;
|
||||
const KEYCAP_SEQUENCE = "[0-9#*]\\uFE0F?\\u20E3";
|
||||
const EMOJI_SEQUENCE_OR_EMPTY_CHARACTER_REGEX = new RegExp(
|
||||
`(${EMOJI_SEQUENCE})|${EMPTY_CHARACTERS.join("|")}`,
|
||||
`(${EMOJI_SEQUENCE}|${KEYCAP_SEQUENCE})|${EMPTY_CHARACTERS.join("|")}`,
|
||||
"gu",
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user