QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.67k stars 1.29k forks source link

[🐞] `trailingSlash:false` doesn't effect at the root path with query string. #5048

Open genki opened 1 year ago

genki commented 1 year ago

Which component is affected?

Qwik City (routing)

Describe the bug

Configured the Qwik City as qwikCity({trailingSlash:false}) in vite config, all routes turned to be without the trailing slash except the root path with query string. The URL like this https://example.com?foo=bar is redirected to https://example.com/?foo=bar although https://example.com and https://example.com/todo?foo=bar doesn't. I think this is not consistent.

Reproduction

https://stackblitz.com/edit/qwik-starter-znqffd?file=src%2Froutes%2Findex.tsx

Steps to reproduce

See the top page and "demo" page linked from the top page. These two pages show the loc.url at the top. Due to the stackblitz's behaviour, we need to reload for each page view to show the real url. As we cannot see the real address bar, the behaviour of the reproduction is slightly different from the real.

System Info

System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M2
    Memory: 87.33 MB / 24.00 GB
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.5.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - /opt/homebrew/bin/npm
    pnpm: 8.6.11 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 116.0.5845.110
    Safari: 16.5.2
  npmPackages:
    @builder.io/partytown: ^0.8.0 => 0.8.0 
    undici: 5.22.1 => 5.22.1 
    vite: 4.4.7 => 4.4.7

Additional Information

No response

mhevery commented 1 year ago

Sorry, can you be more specific on how to reproduce this?

What do I click on? What is expected? What happens instead.

genki commented 1 year ago

@mhevery Sorry, it's difficult because the stackblitz has only a fake navigation bar so we can't see the real URL redirected to. Could you use any of your qwik app to have configured that the trailingSlash:false? And then append the query string in the navigation bar like thishttps://yourapp.com?foo=bar. It will be redirected to https://yourapp.com/?foo=bar even if we have configured trailingSlash:false. I expect to see https://yourapp.com?foo=bar in the navigation bar.