fix(ContextMenuCommandBuilder): allow emoji in name (#10790)

* fix(ContextMenuCommandBuilder): allow emoji in name

* test: add emoji from 16.0

https://emojipedia.org/fingerprint

* chore: non rule-breaking regex

* feat: use simplified regex

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

* style: prettier

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
Denis-Adrian Cristea
2025-03-05 14:15:54 +02:00
committed by GitHub
parent d1f56ffb2a
commit 28a945069f
2 changed files with 6 additions and 2 deletions

View File

@@ -27,6 +27,11 @@ describe('Context Menu Commands', () => {
// Translation: thx (according to GTranslate)
expect(() => getBuilder().setName('どうも')).not.toThrowError();
expect(() => getBuilder().setName('🎉').toJSON()).not.toThrowError();
expect(() => getBuilder().setName('🫆').toJSON()).not.toThrowError();
expect(() => getBuilder().setName('🎉 abc').toJSON()).not.toThrowError();
expect(() => getBuilder().setName('🫆 abc').toJSON()).not.toThrowError();
});
});

View File

@@ -6,8 +6,7 @@ const namePredicate = z
.string()
.min(1)
.max(32)
// eslint-disable-next-line prefer-named-capture-group
.regex(/^( *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}]+ *)+$/u);
.regex(/^(?:(?: *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}\p{Extended_Pictographic}\p{Emoji_Component}]) *)+$/u);
const contextsPredicate = z.array(z.nativeEnum(InteractionContextType));
const integrationTypesPredicate = z.array(z.nativeEnum(ApplicationIntegrationType));