Fix jumbo emoji detection broken by production minifier.

Replace surrogate-pair emoji regex with Unicode property escapes so Rolldown no longer corrupts matching in production builds.
This commit is contained in:
2026-07-22 20:28:59 +10:00
parent ae70eae0fc
commit e7777f42d8
3 changed files with 24 additions and 9 deletions

View File

@@ -31,7 +31,7 @@ import {
mxcUrlToHttp,
} from '../utils/matrix';
import { getMemberDisplayName } from '../utils/room';
import { EMOJI_PATTERN, sanitizeForRegex, URL_NEG_LB } from '../utils/regex';
import { EMOJI_REG_G, sanitizeForRegex } from '../utils/regex';
import { getHexcodeForEmoji, getShortcodeFor } from './emoji';
import { findAndReplace } from '../utils/findAndReplace';
import {
@@ -48,8 +48,6 @@ import { openExternalUrl } from '../utils/tauri';
const ReactPrism = lazy(() => import('./react-prism/ReactPrism'));
const EMOJI_REG_G = new RegExp(`${URL_NEG_LB}(${EMOJI_PATTERN})`, 'g');
/**
* Click handler for external links - uses Tauri shell on desktop/mobile
*/

View File

@@ -13,13 +13,18 @@ export const findAndReplace = <ReplaceReturnType, ConvertReturnType>(
const result: Array<ReplaceReturnType | ConvertReturnType> = [];
let lastEnd = 0;
regex.lastIndex = 0;
let match: RegExpExecArray | RegExpMatchArray | null = regex.exec(text);
while (match !== null && typeof match.index === 'number') {
result.push(convertPart(text.slice(lastEnd, match.index), result.length));
result.push(replace(match, result.length));
lastEnd = match.index + match[0].length;
if (match[0].length === 0) {
regex.lastIndex += 1;
}
if (regex.global) match = regex.exec(text);
else break;
}
result.push(convertPart(text.slice(lastEnd), result.length));

File diff suppressed because one or more lines are too long