Skip to content

Commit

Permalink
fix: remove utf-8 encoding from contents
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash committed Dec 17, 2023
1 parent ef19a86 commit c8ac618
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/utils/serveFromHar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ function findEntry(
return bestEntry?.entry ?? null;
}

async function parseContent(content: Content & { _file?: string }, dirName: string = ".") {
async function parseContent(
content: Omit<Content & { _file?: string }, "text"> & { text: Buffer | string },
dirName: string = ".",
) {
if (!content) return undefined;
if (content._file && !content.text) {
const contentFilePath = path.join(dirName, content._file);
content.text = await promises.readFile(contentFilePath, {
encoding: "utf8",
});
content.text = await promises.readFile(contentFilePath);
}
if (!content.text) return undefined;
if (content.encoding === "base64") {
if (content.encoding === "base64" && typeof content.text === "string") {
return Buffer.from(content.text, "base64");
} else {
return content.text;
Expand Down

0 comments on commit c8ac618

Please sign in to comment.