Skip to content

Bug: MockAgent intercepts don't handle params with square brackets #4146

@dario-piotrowicz

Description

@dario-piotrowicz

Bug Description

MockAgent#intercept doesn't seem to support query params with square brackets for requests such as:
https://example.com/qux-c?arraykey[]=a&arraykey[]=b

Reproducible By

You can fine a minimal reproduction of this issue here: https://github.com/dario-piotrowicz/undici-square-params-repro

Expected Behavior

Such parameters should be supported, meaning that requests to https://example.com/qux-c?arraykey=a&arraykey=b and
https://example.com/qux-c?arraykey[]=a&arraykey[]=b should work practically in the same exact way

Environment

Mac OS Sequoia 15.3.2

Additional context

It seems like there is no consensus on the syntax for array search params (medium article) but that this syntax with square brackets is generally supported. (Someone also told me that there are/where some php frameworks that would only accept this syntax).

I've encountered this when trying to unit test code using the stripe-node package, it seems like the stripe platform enforces such syntax (stripe docs reference) so this is not really work-aroundable as far as I can tell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions