fix(escapeX): emojis with underlines (#8945)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2022-12-25 20:04:26 +00:00
committed by GitHub
parent 36560c9955
commit 07b597df16
2 changed files with 16 additions and 2 deletions

View File

@@ -185,7 +185,7 @@ function escapeItalic(text) {
return `\\*${match}`;
});
i = 0;
return text.replace(/(?<=^|[^_])_([^_]|__|$)/g, (_, match) => {
return text.replace(/(?<=^|[^_])(?<!<a?:.+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
if (match === '__') return ++i % 2 ? `\\_${match}` : `${match}\\_`;
return `\\_${match}`;
});
@@ -211,7 +211,7 @@ function escapeBold(text) {
*/
function escapeUnderline(text) {
let i = 0;
return text.replace(/__(_)?/g, (_, match) => {
return text.replace(/(?<!<a?:.+)__(_)?(?!:\d+>)/g, (_, match) => {
if (match) return ++i % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
return '\\_\\_';
});