diff --git a/src/query.ts b/src/query.ts index 51925ff8..4f202c50 100644 --- a/src/query.ts +++ b/src/query.ts @@ -70,5 +70,6 @@ export function stringifyQuery(query: QueryObject) { return Object.keys(query) .filter((k) => query[k] !== undefined) .map((k) => encodeQueryItem(k, query[k])) + .filter(Boolean) .join("&"); } diff --git a/test/query.test.ts b/test/query.test.ts index e7d446d4..55cdc833 100644 --- a/test/query.test.ts +++ b/test/query.test.ts @@ -59,6 +59,11 @@ describe("withQuery", () => { query: { param: { a: [{ obj: [1, 2, 3] }] } }, out: "/?param=%7B%22a%22:%5B%7B%22obj%22:%5B1,2,3%5D%7D%5D%7D", // {"a":[{"obj":[1,2,3]}]} }, + { + input: "/", + query: { 'a': 'X', 'b[]': [], c: "Y" }, + out: "/?a=X&c=Y", + }, ]; for (const t of tests) {