Skip to content

Inconsistent behaviour of "arrayLimit" #294

Description

@Jokero

From readme:

qs will also limit specifying indices in an array to a maximum index of 20. 
Any array members with an index of greater than 20 
will instead be converted to an object with the index as the key

Value 20 is configurable by arrayLimit option.

First of all, arrayLimit as a name for the option is very confusing. I would expect that resulting array will contain no more than arrayLimit items and the rest items will be rejected. However, this is not correct. All values will be parsed but instead of an array I will get an object.

Ok, but what's the problem with arrayLimit. Actually it works only with array defined using bracket form:

ids[]=43750&ids[]=70936&ids[]=94691&...

If I have more than 21 ids in a query string, the resulting value will be parsed as an object:

{
    '0': '43750',
    ...
}

However, if array is defined without brackets, arrayLimit will not be honoured:

ids=43750&ids=70936&ids=94691&...

If I have for example 30 ids in a query string, the resulting value will be parsed as an array:

['43750', '70936', '94691', ...]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions