0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00

fix(deno): 404 error on Serve Static Middleware (#863)

There will be a 404 error when non-standard characters appear in URL.
Add `decodeURI()` to fix it.
This commit is contained in:
Daniel Ding 2023-02-06 05:44:47 +08:00 committed by GitHub
parent a9746b2296
commit ea4129123d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ export const serveStatic = (options: ServeStaticOptions = { root: '' }) => {
const url = new URL(c.req.url)
let path = getFilePath({
filename: options.path ?? url.pathname,
filename: options.path ?? decodeURI(url.pathname),
root: options.root,
defaultDocument: DEFAULT_DOCUMENT,
})