qwik icon indicating copy to clipboard operation
qwik copied to clipboard

Qwik City - Optional route parameters not working as expected from v0.0.33

Open robisim74 opened this issue 3 years ago • 4 comments

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

robisim74 avatar Aug 10 '22 14:08 robisim74

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 avatar Aug 10 '22 15:08 youngboy

@youngboy Already tried, nothing changes

robisim74 avatar Aug 10 '22 15:08 robisim74

created a sample https://stackblitz.com/edit/vitejs-vite-fhmujz?file=src/routes/index.tsx see if it helps?

@robisim74

youngboy avatar Aug 10 '22 15:08 youngboy

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

robisim74 avatar Aug 10 '22 16:08 robisim74