Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert body to string unless octet-stream #1121

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tough-news-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-netlify': patch
---

Convert body to string, unless type is octet-stream
9 changes: 8 additions & 1 deletion packages/adapter-netlify/files/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ export async function handler(event) {
});
}

const rawBody =
headers['content-type'] === 'application/octet-stream'
? new TextEncoder('base64').encode(body).buffer
: isBase64Encoded
? Buffer.from(body, 'base64').toString()
: body;

const rendered = await render({
method: httpMethod,
headers,
path,
query,
rawBody: isBase64Encoded ? new TextEncoder('base64').encode(body).buffer : body
rawBody
});

if (rendered) {
Expand Down
11 changes: 8 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.