Skip to content

Access route result in Not Found during dev when the route is encoded URI #7075

@kwchang0831

Description

@kwchang0831

Describe the bug

Routing result is Not Found if the route is encoded URI during dev server.
eg: With route src/routes/%E5%88%9D%E3%82%81/+page.svelte when navigating to http://localhost:5173/%E5%88%9D%E3%82%81

Not found: /src/routes/%E5%88%9D%E3%82%81/+page.svelte
Error: Not found: /src/routes/%E5%88%9D%E3%82%81/+page.svelte

However, preview works as expected. After pnpm build && pnpm preview, the route http://localhost:4173/%E5%88%9D%E3%82%81 is accessible.

For the reference:

encodeURI('初め') => '%E5%88%9D%E3%82%81'

Reproduction

https://github.com/kwchang0831/issue-sveltekit-already-encoded-route

To Reproduce:

  1. Create a route with encoded URI. eg: src/routes/%E5%88%9D%E3%82%81/+page.svelte.
  2. Set export const prerender = true; in +layout.ts.
  3. Run pnpm dev.
  4. In browser, navigate to the route http://localhost:5173/%E5%88%9D%E3%82%81.

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (12) x64 Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz
    Memory: 22.60 GB / 31.35 GB
    Container: Yes
    Shell: 3.5.1 - /usr/bin/fish
  Binaries:
    Node: 18.7.0 - ~/.asdf/installs/nodejs/18.7.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/shims/yarn
    npm: 8.15.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Firefox: 105.0.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.80 
    @sveltejs/kit: next => 1.0.0-next.505 
    svelte: ^3.44.0 => 3.50.1 
    vite: ^3.1.0 => 3.1.4

Severity

serious, but I can work around it

Additional Information

If the route name is %E5%88 which is not a valid encoded URI, just a arbitrary string, it will result in URIError: URI malformed when access the route.

So, it seems like when handing route name, it assumes that the name is previously encoded or just to make sure the name is not encoded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrouter

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions