fix(rules): handle multi-byte emoji in getLastChar via Array.from

getLastChar used t[t.length-1] which only gets the trailing surrogate
of emoji like 🔚 (U+1F51A, a surrogate pair in UTF-16). This meant
end symbol matching ALWAYS failed for emoji symbols, causing every
non-humanList message to hit rule_match_no_end_symbol -> no-reply.

Fix: use Array.from(t) to correctly split by Unicode code points.
This commit is contained in:
zhi
2026-02-27 15:20:05 +00:00
parent 3749de981f
commit 75f358001b

View File

@@ -43,7 +43,10 @@ function stripTrailingMetadata(input: string): string {
function getLastChar(input: string): string {
const t = stripTrailingMetadata(input).trim();
return t.length ? t[t.length - 1] : "";
if (!t.length) return "";
// Use Array.from to handle multi-byte characters (emoji, surrogate pairs)
const chars = Array.from(t);
return chars[chars.length - 1] || "";
}
export function resolvePolicy(config: WhisperGateConfig, channelId?: string, channelPolicies?: Record<string, ChannelPolicy>) {