Skip to content

Commit

Permalink
Fix query params splitting (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjkb committed May 18, 2021
1 parent 261ee1c commit 1ba1784
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
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

0 comments on commit 1ba1784

Please sign in to comment.