Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR: This fixes an issue where query bindings would not work for slices due to the way browsers would pass them.
Consider a struct like this:
Binding that struct using Echo's
ctx.Bind
function would work, as long as the request only contains query parameters which exactly match thequery
tag, like this:This is expected and works as it should. The HTTP spec even says that it's completely fine to pass the same query value multiple times.
However, major browsers (I've tested Firefox and Chromium), when asked to construct a query from an array, will create a query string like this:
Notice the additional
[]
in the string. The spec is somewhat murky on this and it seems there are differences between languages. Echo only supports the first version and will treat[]
suffixes on query parameters as literal values. Creating a struct likevalues[]
will pass that in, but then I need more custom logic to parse that if I want to support both. This PR fixes that.The fix I'm proposing here is the simplest I could come up with. It might not be the best or optimal.