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

Fix adapter-netlify query params splitting (#1466) #1467

Merged
merged 3 commits into from
May 18, 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/cool-hounds-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-netlify': patch
---

Prevent adapter from splitting query params if they contain commas
5 changes: 5 additions & 0 deletions .changeset/little-shirts-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-begin': patch
---

Prevent adapter from splitting query params if they contain commas
10 changes: 2 additions & 8 deletions packages/adapter-begin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ import url from 'url';
import app from '@architect/shared/app.js'; // eslint-disable-line import/no-unresolved

async function handler(event) {
const { host, rawPath: path, httpMethod, headers, queryStringParameters, body } = event;
const { host, rawPath: path, httpMethod, rawQueryString, headers, body } = event;

const query = new url.URLSearchParams();
for (const k in queryStringParameters) {
const value = queryStringParameters[k];
value.split(', ').forEach((v) => {
query.append(k, v);
});
}
const query = new url.URLSearchParams(rawQueryString);

const rendered = await app.render({
host,
Expand Down
10 changes: 2 additions & 8 deletions packages/adapter-netlify/files/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ import '@sveltejs/kit/install-fetch'; // eslint-disable-line import/no-unresolve
import { render } from '../output/server/app.js'; // eslint-disable-line import/no-unresolved

export async function handler(event) {
const { path, httpMethod, headers, queryStringParameters, body, isBase64Encoded } = event;
const { path, httpMethod, headers, rawQuery, body, isBase64Encoded } = event;

const query = new URLSearchParams();
for (const k in queryStringParameters) {
const value = queryStringParameters[k];
value.split(', ').forEach((v) => {
query.append(k, v);
});
}
const query = new URLSearchParams(rawQuery);

const rawBody =
headers['content-type'] === 'application/octet-stream'
Expand Down