Skip to content

Router queryStringArrayFormat: 'brackets' option doesn't work as expected #2375

@Jacobtims

Description

@Jacobtims

Version:

  • @inertiajs/react version: 2.0.11

Describe the problem:

The queryStringArrayFormat option on both the router.get() and router.reload() doesn't work as expected. It encodes the brackets, but I expect them to remain as normal (decoded) brackets.

When I do this:

router.reload({
    data: {
        random_array: ['test123', 'test213', 'dsadsa'],
    },
    queryStringArrayFormat: 'brackets',
});

I expect the URI to look like this:

/dashboard?random_array[0]=test123&random_array[1]=test213&random_array[2]=dsadsa

But instead it looks like this:

/dashboard?random_array%5B0%5D=test123&random_array%5B1%5D=test213&random_array%5B2%5D=dsadsa

Steps to reproduce:

  1. Add a router.reload() or router.get() call with the queryStringArrayFormat option set to "brackets".
  2. Call the function.
  3. See that the URI in the browser contains encoded brackets instead of normal (decoded) brackets.

I am aware that there is already an issue open related to this (inertia/issues/1709), but this is on Inertia version 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    reactRelated to the react adapter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions