From d2284c72fdcf518e6b5d08d6f5f1575d6cf431ea Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 5 Jul 2024 16:29:33 +0700 Subject: [PATCH] fixed bug in toSearchParams where null values would be included as key=null which would be considered the string null on the other end. We're now filtering out null values before converting to URLSearchParams. This was causing Create project from draft to fail for projects created without an org. --- frontend/src/lib/util/query-params.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/util/query-params.ts b/frontend/src/lib/util/query-params.ts index 6c8324c7f..b62a84c3b 100644 --- a/frontend/src/lib/util/query-params.ts +++ b/frontend/src/lib/util/query-params.ts @@ -67,7 +67,9 @@ function getDefaults>( * https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1568#issuecomment-1587963141 */ export function toSearchParams(params: T): string { - const searchParams = new URLSearchParams(params as unknown as Record); + //filter out null values + const paramsWithoutNull = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== null)); + const searchParams = new URLSearchParams(paramsWithoutNull as unknown as Record); return searchParams.toString(); }