question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ not working in route paths

See original GitHub issue

Describe the bug

Routes containing @ appear to have been broken in @sveltejs/kit 1.0.0-next.163 and result in a 404 error. 162 is working as expected, 163-165 reproduce the issue.

Reproduction

npm init svelte@next
npm install

create file src/routes/@test.svelte with the following contents:

<h1>@test</h1>

run npm run dev

browsing to this url http://localhost:3000/@test displays 404 Not found: /@test error page.

changing @sveltejs/kit from next to 1.0.0-next.162 in package.json, and then running npm i && npm run dev results in the @test page properly loading.

Logs

No response

System Info

System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (4) x64 Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz
    Memory: 7.19 GB / 15.47 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.9.1 - ~/.n/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 7.23.0 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 93.0.4577.63
    Firefox: 92.0
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.165 
    svelte: ^3.34.0 => 3.42.5

Severity

serious, but I can work around it

Additional Information

I am using a src/routes/@[username] path in my application for user profile pages, and they are all resulting in 404 errors now. I can technically work around the issue by refactoring my app to use a different user profile path, but I’d really like to avoid that if possible.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
benmccanncommented, Sep 14, 2021

Making it work correctly for #, @, and / seems challenging. I think we would have to change the pattern from a single pattern to an array of patterns first splitting on / and then matching against each decoded path segment

0reactions
benmccanncommented, Sep 15, 2021

Hmm. That doesn’t work.

decodeURIComponent(encodeURI(decodeURI('AC%2fDC'))) returns AC%2fDC while decodeURIComponent('AC%2fDC') returns AC/DC because the first decodeURI leaves the % alone and then it gets encoded again with encodeURI

Maybe what we need to do instead is manually decode the characters that decodeURI doesn’t?

Read more comments on GitHub >

github_iconTop Results From Across the Web

2 - Stack Overflow
Here is an example of my routes in my application. ``` <Router> <AppContainer> <Route component={Header} /> <Switch> <Route exact path="/" ...
Read more >
Routing in React - Pragim Tech
We have another Problem to address. Though Router finds a matching Route, it continues to search all the remaining routes as well to...
Read more >
Ultimate React Router v6 Guide
React Router is by far the most popular routing library in React and this article goes in depth on everything you need to...
Read more >
Migrating to React Router v6: A complete guide
Path -matching issues. Routes queries route paths with the most similar naming instead of with exact naming. For instance, a route name ...
Read more >
Routes not working in react router - Questions - OneCompiler
The problem is with the Nav Route, It is the base route to all routes. So, you need to tell react router that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found