Skip to content

Commit c8ac618

Browse files
committed
fix: remove utf-8 encoding from contents
1 parent ef19a86 commit c8ac618

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/utils/serveFromHar.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ function findEntry(
6262
return bestEntry?.entry ?? null;
6363
}
6464

65-
async function parseContent(content: Content & { _file?: string }, dirName: string = ".") {
65+
async function parseContent(
66+
content: Omit<Content & { _file?: string }, "text"> & { text: Buffer | string },
67+
dirName: string = ".",
68+
) {
6669
if (!content) return undefined;
6770
if (content._file && !content.text) {
6871
const contentFilePath = path.join(dirName, content._file);
69-
content.text = await promises.readFile(contentFilePath, {
70-
encoding: "utf8",
71-
});
72+
content.text = await promises.readFile(contentFilePath);
7273
}
7374
if (!content.text) return undefined;
74-
if (content.encoding === "base64") {
75+
if (content.encoding === "base64" && typeof content.text === "string") {
7576
return Buffer.from(content.text, "base64");
7677
} else {
7778
return content.text;

0 commit comments

Comments
 (0)