Unverified Commit b20d5f2d authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Fix metadata image route encoding (#49482)

Fix the bad encoded buffer introduced in #49323
parent 00ed2ba7
......@@ -51,13 +51,11 @@ const contentType = ${JSON.stringify(getContentType(resourcePath))}
const buffer = Buffer.from(${JSON.stringify(
(
await fs.promises.readFile(
resourcePath.replace(METADATA_RESOURCE_QUERY, ''),
{
encoding: 'utf-8',
}
resourcePath.replace(METADATA_RESOURCE_QUERY, '')
)
).toString()
)})
).toString('base64')
)}, 'base64'
)
export function GET() {
return new NextResponse(buffer, {
......
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
import { BrowserInterface } from 'test/lib/browsers/base'
import fs from 'fs/promises'
import path from 'path'
import cheerio from 'cheerio'
createNextDescribe(
......@@ -8,7 +10,7 @@ createNextDescribe(
{
files: __dirname,
},
({ next, isNextDev, isNextStart }) => {
({ next, isNextDev, isNextStart, isNextDeploy }) => {
const getTitle = (browser: BrowserInterface) =>
browser.elementByCss('title').text()
......@@ -568,6 +570,18 @@ createNextDescribe(
const icon = $('link[rel="icon"]')
expect(icon.attr('href')).toBe('/favicon.ico')
expect(icon.attr('sizes')).toBe('any')
if (!isNextDeploy) {
const faviconFileBuffer = await fs.readFile(
path.join(next.testDir, 'app/favicon.ico')
)
const faviconResponse = Buffer.from(
await next.fetch('/favicon.ico').then((res) => res.arrayBuffer())
)
return expect(
Buffer.compare(faviconResponse, faviconFileBuffer)
).toBe(0)
}
})
})
......
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