Skip to content

Commit

Permalink
fix metion preview with invalid phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed Jun 10, 2024
1 parent 6c07092 commit 15b5475
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ export default class ExpensiMark {
return `${g1}<mention-user>${g2}${phoneRegex.test(g2) ? `@${Constants.CONST.SMS.DOMAIN}` : ''}</mention-user>`;
},
rawInputReplacement: (match, g1, g2) => {
if (!Str.isValidMention(match)) {
const phoneNumberRegex = new RegExp(`^${Constants.CONST.REG_EXP.PHONE_PART}$`);
const mention = g2.slice(1);
const mentionWithoutSMSDomain = Str.removeSMSDomain(mention);
if (!Str.isValidMention(match) || (phoneNumberRegex.test(mentionWithoutSMSDomain) && !Str.isValidPhoneNumber(mentionWithoutSMSDomain))) {
return match;
}
return `${g1}<mention-user>${g2}</mention-user>`;
Expand Down

0 comments on commit 15b5475

Please sign in to comment.