Skip to content

Commit

Permalink
fix: calling response.json() in middleware will cause garbled chinese…
Browse files Browse the repository at this point in the history
… characters
  • Loading branch information
Val-istar-Guo committed Feb 25, 2022
1 parent 9040396 commit 40ffe02
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/keq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ export class Keq<T> {
return async() => {
if (!cache) cache = await target.arrayBuffer()

const res = new Response(cache, { headers: target.headers })
const res = new Response(
new TextDecoder().decode(cache),
{ headers: target.headers },
)

res.formData = resFromData.bind(res)
return await res[property]() as unknown
}
Expand Down

0 comments on commit 40ffe02

Please sign in to comment.