Fix timelines

This commit is contained in:
Jesse Wierzbinski 2023-11-26 12:46:15 -10:00
parent 8c870cdad3
commit 0a74bbfe93
No known key found for this signature in database
7 changed files with 22 additions and 13 deletions

View file

@ -11,6 +11,7 @@ export async function parseRequest<T>(request: Request): Promise<Partial<T>> {
// Parse SearchParams arrays into JSON arrays
const arrayKeys = [...query.keys()].filter(key => key.endsWith("[]"));
const nonArrayKeys = [...query.keys()].filter(key => !key.endsWith("[]"));
for (const key of arrayKeys) {
const value = query.getAll(key);
@ -18,6 +19,12 @@ export async function parseRequest<T>(request: Request): Promise<Partial<T>> {
query.append(key, JSON.stringify(value));
}
// Append non array keys to output
for (const key of nonArrayKeys) {
// @ts-expect-error Complains about type
output[key] = query.get(key);
}
const queryEntries = [...query.entries()];
if (queryEntries.length > 0) {