Skip to content

Commit

Permalink
Change emoji regex to support older JS runtimes #599
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed May 24, 2024
1 parent 51d1e98 commit 8819268
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
38 changes: 21 additions & 17 deletions library/src/actions/emoji/emoji.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,30 @@ describe('emoji', () => {
]);
});

test('for numbers', () => {
expectActionIssue(action, baseIssue, [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0123456789',
]);
});
// TODO: This test needs to be enabled after upgrading the emoji regex.
// See the comment in `regex.ts` for more details.
// test('for numbers', () => {
// expectActionIssue(action, baseIssue, [
// '0',
// '1',
// '2',
// '3',
// '4',
// '5',
// '6',
// '7',
// '8',
// '9',
// '0123456789',
// ]);
// });

test('for special chars', () => {
expectActionIssue(action, baseIssue, [
'#',
'*',
// TODO: These chars needs to be enabled after upgrading the emoji regex.
// See the comment in `regex.ts` for more details.
// '#',
// '*',
'!',
'@',
'$',
Expand Down
6 changes: 5 additions & 1 deletion library/src/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export const EMAIL_REGEX =
/**
* Emoji regex.
*/
export const EMOJI_REGEX = /^\p{RGI_Emoji}+$/v;
export const EMOJI_REGEX = /^[\p{Extended_Pictographic}\p{Emoji_Component}]+$/u;

// This emoji regex is not supported in Node.js v18 and older browsers.
// Therefore, we are postponing the switch to this regex to a later date.
// export const EMOJI_REGEX = /^\p{RGI_Emoji}+$/v;

/**
* [Hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) regex.
Expand Down

0 comments on commit 8819268

Please sign in to comment.