diff --git a/src/lib/serialize.ts b/src/lib/serialize.ts index ef82067..b32131b 100644 --- a/src/lib/serialize.ts +++ b/src/lib/serialize.ts @@ -33,7 +33,7 @@ const nestedUpdateUrlSearchParams = ( const currentPath = [...path, key] if (isPlainObject(value)) { nestedUpdateUrlSearchParams(searchParams, value, currentPath) - return + continue } const name = currentPath.join('.') diff --git a/test/serialization.test.ts b/test/serialization.test.ts index 7efb43f..20bfa1d 100644 --- a/test/serialization.test.ts +++ b/test/serialization.test.ts @@ -108,6 +108,30 @@ test('serializes plain objects', (t) => { }), 'bar.baz=1&bar.baz=a&foo=1', ) + + t.is( + serializeUrlSearchParams({ + foo: {}, + bar: 2, + }), + 'bar=2', + ) + + t.is( + serializeUrlSearchParams({ + foo: { x: {} }, + bar: 2, + }), + 'bar=2', + ) + + t.is( + serializeUrlSearchParams({ + foo: {}, + bar: { baz: { x: { z: null, t: {} }, q: {} } }, + }), + 'bar.baz.x.z=', + ) }) test('cannot serialize keys containing a .', (t) => {