mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-19 17:11:45 +00:00
fix(line): preserve Unicode boundaries in recipient errors (#104109)
This commit is contained in:
@@ -384,6 +384,24 @@ describe("LINE send helpers", () => {
|
||||
expect(pushMessageMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves UTF-16 boundaries in invalid recipient diagnostics", async () => {
|
||||
await expect(
|
||||
sendModule.pushMessagesLine(`aab😀${"x".repeat(40)}`, [{ type: "text", text: "hello" }], {
|
||||
cfg: LINE_TEST_CFG,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
"Recipient is not a valid LINE id (case-sensitive; expected leading capital C/U/R): aab…",
|
||||
);
|
||||
await expect(
|
||||
sendModule.pushMessagesLine(`aa😀${"y".repeat(40)}`, [{ type: "text", text: "hello" }], {
|
||||
cfg: LINE_TEST_CFG,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
"Recipient is not a valid LINE id (case-sensitive; expected leading capital C/U/R): aa😀…",
|
||||
);
|
||||
expect(pushMessageMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("accepts case-exact LINE recipients with the leading capital preserved", async () => {
|
||||
await sendModule.pushMessagesLine(
|
||||
"Cabcdef0123456789abcdef0123456789",
|
||||
|
||||
@@ -79,7 +79,7 @@ function normalizeTarget(to: string): string {
|
||||
// fixtures (e.g. "U123") are left alone. openclaw/openclaw#81628
|
||||
if (normalized.length >= 33 && !/^[CUR]/.test(normalized)) {
|
||||
throw new Error(
|
||||
`Recipient is not a valid LINE id (case-sensitive; expected leading capital C/U/R): ${normalized.slice(0, 4)}…`,
|
||||
`Recipient is not a valid LINE id (case-sensitive; expected leading capital C/U/R): ${truncateUtf16Safe(normalized, 4)}…`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user