Skip to content

Commit

Permalink
fixed bug in toSearchParams where null values would be included as ke…
Browse files Browse the repository at this point in the history
…y=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.
  • Loading branch information
hahn-kev committed Jul 5, 2024
1 parent 2a47ab9 commit d2284c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/lib/util/query-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function getDefaults<T extends Record<string, unknown>>(
* https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1568#issuecomment-1587963141
*/
export function toSearchParams<T extends PrimitiveRecord>(params: T): string {
const searchParams = new URLSearchParams(params as unknown as Record<string, string>);
//filter out null values
const paramsWithoutNull = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== null));
const searchParams = new URLSearchParams(paramsWithoutNull as unknown as Record<string, string>);
return searchParams.toString();
}

Expand Down

0 comments on commit d2284c7

Please sign in to comment.