unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

fix(public-assets): do not shadow paths that share prefix #2516

Closed danielroe closed 3 months ago

danielroe commented 3 months ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

Encountered this as a side effect of replicating another bug.

Registering public asset dir with a base URL of, say, /custom will lead to paths like /custom-thing also being handled by the same handler (and returning a hard 404 if fallthrough is disabled). This is because we do not test if the path begins with /custom/ but with /custom.

Let me know if you need me to provide a reproduction. I think the problem and fix are straightforward to see, but happy to do so!

๐Ÿ“ Checklist