Fix rendering TextEncoder encoding error regression (#7777)

This commit is contained in:
Bjorn Lu 2023-07-24 16:22:05 +08:00 committed by GitHub
parent 0c9959704f
commit 3567afac44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix rendering TextEncoder encoding error regression

View file

@ -124,7 +124,8 @@ export function chunkToByteArray(
if (ArrayBuffer.isView(chunk)) {
return chunk as Uint8Array;
} else {
// stringify chunk might return a HTMLString
return encoder.encode(stringifyChunk(result, chunk));
// `stringifyChunk` might return a HTMLString, call `.toString()` to really ensure it's a string
const stringified = stringifyChunk(result, chunk);
return encoder.encode(stringified.toString());
}
}