Skip to content

allowEmptyArrays option disrespects arrayFormat #525

Open
deepshekhardas/qs
#1

Description

@cdpark0530

allowEmptyArrays option was intruduced in version 6.12.0

Without this option

qs.stringify({ foo: [], bar: baz })
// 'bar=baz'

With this option

qs.stringify({ foo: [], bar: baz }, { allowEmptyArrays: true })
// 'foo[]&bar=baz'

However, I believe that with arrayFormat: 'comma' option, it should result like this:

qs.stringify({ foo: [], bar: baz }, { allowEmptyArrays: true, arrayFormat: 'comma' })
// 'foo=&bar=baz'

Activity

  1. ljharb commented on Jun 19, 2025

    @ljharb
    Owner

    I understand that expectation, but when commaRoundTrip is anything but true, comma does a bunch of weird stuff, and when commaRoundTrip is true, i think 'foo[]&bar=baz' would be the expected output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions