ElMassimo / iles

🏝 The joyful site generator
https://iles.pages.dev
MIT License
1.07k stars 31 forks source link

File names of dynamic routes in the build output should not be URI-encoded #167

Closed ouuan closed 2 years ago

ouuan commented 2 years ago

Description 📖

The file names of dynamic routes are URI-encoded in the build output which breaks the links.

Reproduction 🐞

https://github.com/ouuan/iles-uri-encoding-broken-link-demo

The build outputs:

dist
├── foo%20bar.html
├── foobar.html
├── index.html
└── static foo bar.html

Here foo%20bar is generated from a dynamic route, and static foo bar is a static route.

/foo bar breaks, and we need to access it via /foo%2520bar.

ElMassimo commented 2 years ago

Thanks for reporting!

Probably encoded by routes.resolve here.

Using decodeURIComponent when obtaining the outputFilename should fix it, and pathToFilename is probably the best place to do that.

PRs are welcome, otherwise I'll take a look during the weekend.

ouuan commented 2 years ago

I'm not sure how to handle the slash character 🤔 It seems that the slash should be encoded.

ElMassimo commented 2 years ago

Perhaps path.split('/').map(decodeURIComponent).join('/')?

Otherwise, it might be a good idea to use some of the encoding utilities already available in vue-router.