Qwik City - Optional route parameters not working as expected from v0.0.33
Qwik Version
0.0.42
Operating System (or Browser)
Chrome/Firefox
Node Version (if applicable)
No response
Which component is affected?
Qwik City
Expected Behaviour
From the docs:
- src/
- routes/
- sku/
- [skuId]/
- index.js # https://example.com/sku/1234
- details.js # https://example.com/sku/1234/details
https://example.com/sku/[skuId]
Will match: https://example.com/sku/1234
Will match: https://example.com/sku/xyz-567
https://example.com/sku/[skuId]/details
Will match: https://example.com/sku/1234/details
Actual Behaviour
At the moment the navigation above is not working: always redirects to index, and when you navigate to https://example.com/sku/1234/details, skuId parameter contains all the final segments: 1234/details
EDIT
The issue occurs when the parameter is optional: [...skuId]. See comments and reproduction below
Additional Information
It worked as expexted until Qwik City 0.0.30
route is defined by directory not file, so maybe change to this will work
- routes/
- sku/
- [skuId]/
- index.js # https://example.com/sku/1234
- [details]/
- index.js # https://example.com/sku/1234/details
checkout the latest docs https://qwik.builder.io/qwikcity/routing/overview#directory-based-routing
@youngboy Already tried, nothing changes
created a sample https://stackblitz.com/edit/vitejs-vite-fhmujz?file=src/routes/index.tsx see if it helps?
@robisim74
Ok, I found that the issue is only when the parameter is optional [...skuId]:
https://stackblitz.com/edit/vitejs-vite-bnu3y4?file=src%2Froutes%2Fsku%2F[...skuId]%2Findex.ts