parent
aa1e9676f1
commit
44a21f4cc2
4 changed files with 38 additions and 0 deletions
|
@ -5,6 +5,7 @@ import send from 'next/dist/compiled/send'
|
|||
// Although "mime" has already add avif in version 2.4.7, "send" is still using mime@1.6.0
|
||||
send.mime.define({
|
||||
'image/avif': ['avif'],
|
||||
'image/x-icns': ['icns'],
|
||||
})
|
||||
|
||||
export function serveStatic(
|
||||
|
|
BIN
test/integration/image-optimizer/app/public/test.icns
Normal file
BIN
test/integration/image-optimizer/app/public/test.icns
Normal file
Binary file not shown.
BIN
test/integration/image-optimizer/app/public/test.pic
Normal file
BIN
test/integration/image-optimizer/app/public/test.pic
Normal file
Binary file not shown.
|
@ -174,6 +174,43 @@ export function runTests(ctx) {
|
|||
expect(res.status).toBe(200)
|
||||
})
|
||||
|
||||
it('should maintain icns', async () => {
|
||||
const query = { w: ctx.w, q: 90, url: '/test.icns' }
|
||||
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, {})
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('Content-Type')).toContain('image/x-icns')
|
||||
expect(res.headers.get('Cache-Control')).toBe(
|
||||
`public, max-age=${isDev ? 0 : minimumCacheTTL}, must-revalidate`
|
||||
)
|
||||
expect(res.headers.get('Vary')).toBe('Accept')
|
||||
expect(res.headers.get('etag')).toBeTruthy()
|
||||
expect(res.headers.get('Content-Disposition')).toBe(
|
||||
`${contentDispositionType}; filename="test.icns"`
|
||||
)
|
||||
await expectWidth(res, 256)
|
||||
})
|
||||
|
||||
it('should maintain pic/pct', async () => {
|
||||
const query = { w: ctx.w, q: 90, url: '/test.pic' }
|
||||
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, {})
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('Content-Type')).toContain('image/x-pict')
|
||||
expect(res.headers.get('Cache-Control')).toBe(
|
||||
`public, max-age=${isDev ? 0 : minimumCacheTTL}, must-revalidate`
|
||||
)
|
||||
expect(res.headers.get('Vary')).toBe('Accept')
|
||||
expect(res.headers.get('etag')).toBeTruthy()
|
||||
expect(res.headers.get('Content-Disposition')).toBe(
|
||||
`${contentDispositionType}; filename="test.pic"`
|
||||
)
|
||||
const actual = await res.text()
|
||||
const expected = await fs.readFile(
|
||||
join(ctx.appDir, 'public', 'test.pic'),
|
||||
'utf8'
|
||||
)
|
||||
expect(actual).toMatch(expected)
|
||||
})
|
||||
|
||||
it('should maintain animated gif', async () => {
|
||||
const query = { w: ctx.w, q: 90, url: '/animated.gif' }
|
||||
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, {})
|
||||
|
|
Loading…
Reference in a new issue