Skip to content

Commit

Permalink
fix: filter only null and undefined values
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Nov 27, 2023
1 parent 596715b commit 7de5de7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/remix-routes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export function $path(route: string, ...paramsOrQuery: Array<any>) {
if (!query) return path;

if (Array.isArray(query)) {
query = query.filter((q) => q[1]);
query = query.filter(([, value]) => value !== undefined && value !== null);
} else if (typeof query === "object") {
query = Object.fromEntries(
Object.entries(query).filter(([, value]) => value)
Object.entries(query).filter(
([, value]) => value !== undefined && value !== null
)
);
}
if (Object.keys(query).length === 0) return path;
Expand Down

0 comments on commit 7de5de7

Please sign in to comment.