mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 22:44:26 +01:00
feat: support underscore in emoji
This commit is contained in:
@@ -192,6 +192,10 @@ describe('parseTextNote', () => {
|
|||||||
given: ':bunhd:',
|
given: ':bunhd:',
|
||||||
expected: [{ type: 'CustomEmoji', content: ':bunhd:', shortcode: 'bunhd' }],
|
expected: [{ type: 'CustomEmoji', content: ':bunhd:', shortcode: 'bunhd' }],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
given: ':sushi_maguro:',
|
||||||
|
expected: [{ type: 'CustomEmoji', content: ':sushi_maguro:', shortcode: 'sushi_maguro' }],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
given: 'Good morning! :pv:!',
|
given: 'Good morning! :pv:!',
|
||||||
expected: [
|
expected: [
|
||||||
@@ -212,7 +216,7 @@ describe('parseTextNote', () => {
|
|||||||
assert.deepStrictEqual(parsed, expected);
|
assert.deepStrictEqual(parsed, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([':bunhd_hop:', ':hello', '::: NOSTR :::'])(
|
it.each([':bunhd-hop:', ':+1:', ':-1:', ':hello', '::: NOSTR :::'])(
|
||||||
'should parse text note which includes invalid custom emoji ($emoji)',
|
'should parse text note which includes invalid custom emoji ($emoji)',
|
||||||
(content) => {
|
(content) => {
|
||||||
const parsed = parseTextNote(content);
|
const parsed = parseTextNote(content);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ const tagRefRegex = /(?:#\[(?<idx>\d+)\])/g;
|
|||||||
const mentionRegex =
|
const mentionRegex =
|
||||||
/(?<mention>(?<nip19>nostr:)?(?<bech32>(?:npub|note|nprofile|nevent)1[ac-hj-np-z02-9]+))/gi;
|
/(?<mention>(?<nip19>nostr:)?(?<bech32>(?:npub|note|nprofile|nevent)1[ac-hj-np-z02-9]+))/gi;
|
||||||
const hashTagRegex = /#(?<hashtag>[\p{Letter}\p{Number}_]+)/gu;
|
const hashTagRegex = /#(?<hashtag>[\p{Letter}\p{Number}_]+)/gu;
|
||||||
const customEmojiRegex = /:(?<emoji>[a-zA-Z0-9]+):/gu;
|
const customEmojiRegex = /:(?<emoji>\w+):/gu;
|
||||||
|
|
||||||
const parseTextNote = (textNoteContent: string) => {
|
const parseTextNote = (textNoteContent: string) => {
|
||||||
const matches = [
|
const matches = [
|
||||||
|
|||||||
Reference in New Issue
Block a user