@ not working in route paths
See original GitHub issueDescribe 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:
- Created 2 years ago
- Comments:5 (4 by maintainers)
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 segmentHmm. That doesn’t work.
decodeURIComponent(encodeURI(decodeURI('AC%2fDC')))
returnsAC%2fDC
whiledecodeURIComponent('AC%2fDC')
returnsAC/DC
because the firstdecodeURI
leaves the%
alone and then it gets encoded again withencodeURI
Maybe what we need to do instead is manually decode the characters that
decodeURI
doesn’t?