brisa-build / brisa

The Web Platform Framework.
https://brisa.build
MIT License
448 stars 12 forks source link

Query and params are the same. Sometimes an array. #270

Closed AlbertSabate closed 2 months ago

AlbertSabate commented 5 months ago

Currently for an url like:

http://localhost:3001/en/admin/6679fbe17b41431a977163fd/providers/create where 6679fbe17b41431a977163fd is defined as [businessId].

console.log(route.query.businessId, route.params.businessId);

returns:

Screenshot 2024-06-27 at 1 00 18 AM

I won't expect an array on this scenario. I will expect query for ?success=true and params for /lala/[businessId]/lolo.

Maybe query should be called searchparams???? or query be actually both. Then has params and searchparams??

aralroca commented 5 months ago

@AlbertSabate This route does not come from Brisa, it comes from Bun:

https://bun.sh/docs/api/file-system-router

The file-system-router is used, and the route comes with these parameters. Many times it is the same, true, but there are differences in [dynamic] routes.

I recommend you to read the Bun documentation about query and params, I hope it helps!

AlbertSabate commented 5 months ago

Bun docs are correct. According to the docs:

params?: Record<string, string>;
query?: Record<string, string>;

I don't know where the array comes from ... Also in bun params are params and query is query. Brisa mix them up.

Screenshot 2024-06-27 at 1 15 34 AM
AlbertSabate commented 4 months ago

It is an issue with Bunjs. We have opened a bug on their tracker.

More info: https://github.com/oven-sh/bun/issues/12206

AlbertSabate commented 2 months ago

Brisa now uses its own implementation and this bug has been fixed internally. I am closing the issue.