Unverified Commit 530b1461 authored by Steven's avatar Steven Committed by GitHub

Add test for `.ico` image bypass (#19025)

We fixed this in a previous PR but there were no tests for `.ico` so this PR adds a test for it to ensure we don't regress.

Similar to SVG, we bypass ICO because it typically contains multiple sizes in a single file.

Closes #18600 
parent 18494fe3
......@@ -104,6 +104,24 @@ function runTests({ w, isDev, domains }) {
expect(actual).toMatch(expected)
})
it('should maintain ico format', async () => {
const query = { w, q: 90, url: '/test.ico' }
const opts = { headers: { accept: 'image/webp' } }
const res = await fetchViaHTTP(appPort, '/_next/image', query, opts)
expect(res.status).toBe(200)
expect(res.headers.get('Content-Type')).toContain('image/x-icon')
expect(res.headers.get('cache-control')).toBe(
'public, max-age=0, must-revalidate'
)
expect(res.headers.get('etag')).toBeTruthy()
const actual = await res.text()
const expected = await fs.readFile(
join(__dirname, '..', 'public', 'test.ico'),
'utf8'
)
expect(actual).toMatch(expected)
})
it('should maintain jpg format for old Safari', async () => {
const accept =
'image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment