File tree 2 files changed +9
-2
lines changed 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { describe , expect , it } from 'vitest' ;
2
2
3
- import { isASocialNetworkUrl } from '../helpers/regex.helper' ;
3
+ import { isASocialNetworkUrl , removeEmoji } from '../helpers/regex.helper' ;
4
4
5
5
describe ( 'Helpers: Regex' , ( ) => {
6
6
describe ( 'Rule: isASocialNetworkUrl should regex correctly an url' , ( ) => {
@@ -15,4 +15,11 @@ describe('Helpers: Regex', () => {
15
15
expect ( result ) . toBe ( false ) ;
16
16
} ) ;
17
17
} ) ;
18
+ describe ( 'Rule: removeEmoji should remove all emojis from a string' , ( ) => {
19
+ it ( 'removeEmoji() should remove all emojis from a string' , ( ) => {
20
+ const text = '👋 Hello, World!<:SpongebobMock:1136008737669259407>' ;
21
+ const result = removeEmoji ( text ) ;
22
+ expect ( result ) . toBe ( ' Hello, World!' ) ;
23
+ } ) ;
24
+ } ) ;
18
25
} ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ const socialNetworksUrlRegex = new RegExp(
2
2
'^(https?://)?(www.)?(facebook.com|fb.me|twitter.com|vxtwitter.com|instagram.com|linkedin.com|youtube.com|youtu.be|pinterest.com|snapchat.com|tiktok.com)/[a-zA-Z0-9.-/?=&#_]+$' ,
3
3
) ;
4
4
const punctuationRegex = / [ . , ! ? ] / g;
5
- const emojiRegex = / ( \p { Extended_Pictographic } | \p{ Emoji_Component } ) / gu;
5
+ const emojiRegex = / < a ? : . + ? : \d { 10 , 30 } > | \p{ Extended_Pictographic } / gu;
6
6
7
7
export const isASocialNetworkUrl = ( url : string ) : boolean => {
8
8
return socialNetworksUrlRegex . test ( url ) ;
You can’t perform that action at this time.
0 commit comments