lukeed / sirv

An optimized middleware & CLI application for serving static files~!
MIT License
1.07k stars 58 forks source link

`/foo%2Fbar.txt` returns `/foo/bar.txt` #138

Closed sapphi-red closed 1 year ago

sapphi-red commented 2 years ago

/foo%2Fbar.txt returns the same content with /foo/bar.txt. Is this intended?

Reproduction

  1. Open https://stackblitz.com/edit/node-lhxxod?file=index.js
  2. Access https://node-lhxxod--3000.local.webcontainer.io/foo%2Fbar.txt on the right panel

Reason

https://github.com/lukeed/sirv/blob/886cc962a345780cd78f8910cdcf218db2a8d955/packages/sirv/index.js#L171 This is because decodeURIComponent is used instead of decodeURI here.

refs https://github.com/vitejs/vite/pull/8804