-
-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query parameter that is a union of string and string array is incorrectly parsed #1028
Comments
My suspicion is that there's a different behavior if you call:
I think the "problem" here that if you query it with the first approach, the (note: looks like For now, you can either parse it manually (via the |
More info: @hisamafahri I couldn't find any straightforward way to get Eden Treaty to format query array parameters as a comma-separated list - do you know if there's a way? I saw elysiajs/eden#127 which would help. But in any case, doesn't seem like Elysia recognises a comma-separated list out of the box: it('query: string array, non-exploded', async () => {
server.listen(3099)
const res = await fetch('http://localhost:3099/query?tags=a,b,c')
const data = await res.json()
expect(data.tags).toEqual(['a', 'b', 'c'])
}) ...also fails (Elysia parses |
You can do this:
Yes, that one is entering an area of debate whether a framework should handle that or not. It's a matter of preference. But, either way, one of the "hacky" way is by manually parse the request url:
|
What version of Elysia is running?
1.2.10
What platform is your computer?
Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 unknown
What steps can reproduce the bug?
What is the expected behavior?
query.tags
is parsed as['a', 'b', 'c']
(i.e. an array)What do you see instead?
query.tags
is parsed as'a'
(i.e. just the first value)Additional information
No response
Have you try removing the
node_modules
andbun.lockb
and try again yet?No
The text was updated successfully, but these errors were encountered: