mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
fix(serve-static): use application/octet-stream if the mime type is not detected (#3415)
This commit is contained in:
parent
0edb243a74
commit
27a57c3f67
@ -143,6 +143,7 @@ describe('Serve Static Middleware', () => {
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('Content-Encoding')).toBe('br')
|
||||
expect(res.headers.get('Vary')).toBe('Accept-Encoding')
|
||||
expect(res.headers.get('Content-Type')).toBe('application/octet-stream')
|
||||
expect(await res.text()).toBe('Hello in static/hello.unknown.br')
|
||||
})
|
||||
|
||||
|
@ -99,13 +99,8 @@ export const serveStatic = <E extends Env = Env>(
|
||||
}
|
||||
|
||||
if (content) {
|
||||
const mimeType = options.mimes
|
||||
? getMimeType(path, options.mimes) ?? getMimeType(path)
|
||||
: getMimeType(path)
|
||||
|
||||
if (mimeType) {
|
||||
c.header('Content-Type', mimeType)
|
||||
}
|
||||
const mimeType = (options.mimes && getMimeType(path, options.mimes)) || getMimeType(path)
|
||||
c.header('Content-Type', mimeType || 'application/octet-stream')
|
||||
|
||||
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
||||
const acceptEncodingSet = new Set(
|
||||
|
Loading…
Reference in New Issue
Block a user