Skip to content

Commit 71ebecb

Browse files
author
ricael
committed
improv: ajustado a validação aceitar todos os emojis.
1 parent 3960624 commit 71ebecb

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

package-lock.json

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"cors": "^2.8.5",
6767
"dayjs": "^1.11.13",
6868
"dotenv": "^16.4.7",
69+
"emoji-regex": "^10.4.0",
6970
"eventemitter2": "^6.4.9",
7071
"express": "^4.21.2",
7172
"express-async-errors": "^3.1.1",

src/api/controllers/sendMessage.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import {
1717
import { WAMonitoringService } from '@api/services/monitor.service';
1818
import { BadRequestException } from '@exceptions';
1919
import { isBase64, isURL } from 'class-validator';
20+
import emojiRegex from 'emoji-regex';
2021

2122
function isEmoji(str: string) {
2223
if (str === '') return true;
2324

24-
const emojiRegex =
25-
/^[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F000}-\u{1F02F}\u{1F0A0}-\u{1F0FF}\u{1F100}-\u{1F64F}\u{1F680}-\u{1F6FF}]$/u;
26-
return emojiRegex.test(str);
25+
const match = str.match(emojiRegex());
26+
return match?.length === 1 && match[0] === str;
2727
}
2828

2929
export class SendMessageController {

0 commit comments

Comments
 (0)