Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b20d5f2d
Unverified
Commit
b20d5f2d
authored
May 08, 2023
by
Jiachi Liu
Committed by
GitHub
May 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix metadata image route encoding (#49482)
Fix the bad encoded buffer introduced in #49323
parent
00ed2ba7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
next-metadata-route-loader.ts
...t/src/build/webpack/loaders/next-metadata-route-loader.ts
+4
-6
metadata.test.ts
test/e2e/app-dir/metadata/metadata.test.ts
+15
-1
No files found.
packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts
View file @
b20d5f2d
...
@@ -51,13 +51,11 @@ const contentType = ${JSON.stringify(getContentType(resourcePath))}
...
@@ -51,13 +51,11 @@ const contentType = ${JSON.stringify(getContentType(resourcePath))}
const buffer = Buffer.from(
${
JSON
.
stringify
(
const buffer = Buffer.from(
${
JSON
.
stringify
(
(
(
await
fs
.
promises
.
readFile
(
await
fs
.
promises
.
readFile
(
resourcePath
.
replace
(
METADATA_RESOURCE_QUERY
,
''
),
resourcePath
.
replace
(
METADATA_RESOURCE_QUERY
,
''
)
{
encoding
:
'utf-8'
,
}
)
)
).
toString
()
).
toString
(
'base64'
)
)}
)
)}
, 'base64'
)
export function GET() {
export function GET() {
return new NextResponse(buffer, {
return new NextResponse(buffer, {
...
...
test/e2e/app-dir/metadata/metadata.test.ts
View file @
b20d5f2d
import
{
createNextDescribe
}
from
'e2e-utils'
import
{
createNextDescribe
}
from
'e2e-utils'
import
{
check
}
from
'next-test-utils'
import
{
check
}
from
'next-test-utils'
import
{
BrowserInterface
}
from
'test/lib/browsers/base'
import
{
BrowserInterface
}
from
'test/lib/browsers/base'
import
fs
from
'fs/promises'
import
path
from
'path'
import
cheerio
from
'cheerio'
import
cheerio
from
'cheerio'
createNextDescribe
(
createNextDescribe
(
...
@@ -8,7 +10,7 @@ createNextDescribe(
...
@@ -8,7 +10,7 @@ createNextDescribe(
{
{
files
:
__dirname
,
files
:
__dirname
,
},
},
({
next
,
isNextDev
,
isNextStart
})
=>
{
({
next
,
isNextDev
,
isNextStart
,
isNextDeploy
})
=>
{
const
getTitle
=
(
browser
:
BrowserInterface
)
=>
const
getTitle
=
(
browser
:
BrowserInterface
)
=>
browser
.
elementByCss
(
'title'
).
text
()
browser
.
elementByCss
(
'title'
).
text
()
...
@@ -568,6 +570,18 @@ createNextDescribe(
...
@@ -568,6 +570,18 @@ createNextDescribe(
const
icon
=
$
(
'link[rel="icon"]'
)
const
icon
=
$
(
'link[rel="icon"]'
)
expect
(
icon
.
attr
(
'href'
)).
toBe
(
'/favicon.ico'
)
expect
(
icon
.
attr
(
'href'
)).
toBe
(
'/favicon.ico'
)
expect
(
icon
.
attr
(
'sizes'
)).
toBe
(
'any'
)
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
)
}
})
})
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment