Skip to content

Commit 8917491

Browse files
maweibinclaude
andcommitted
fix(http-body): keep emoji / surrogate pairs intact during error body truncation
Use Array.from() to count full code points instead of UTF-16 code units, preventing lone surrogates in diagnostic output. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent 775ef96 commit 8917491

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/infra/http-body.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export async function readResponseTextSnippet(
313313
return undefined;
314314
}
315315
if (collapsed.length > maxChars) {
316-
return `${collapsed.slice(0, maxChars)}…`;
316+
return `${Array.from(collapsed).slice(0, maxChars).join("")}…`;
317317
}
318318
return prefix.truncated ? `${collapsed}…` : collapsed;
319319
}

0 commit comments

Comments
 (0)