Skip to content

Commit 01a1a7f

Browse files
authored
Fix server html insertion target (vercel#42591)
Fixes vercel#42493 Make sure searching for the close head tag instead of partial of head tag ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md`
1 parent b1932b0 commit 01a1a7f

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

packages/next/server/node-web-streams-helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function createHeadInsertionTransformStream(
173173
freezing = true
174174
} else {
175175
const content = decodeText(chunk)
176-
const index = content.indexOf('</head')
176+
const index = content.indexOf('</head>')
177177
if (index !== -1) {
178178
const insertedHeadContent =
179179
content.slice(0, index) + insertion + content.slice(index)

test/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
!node_modules
2+
.vscode
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
experimental: {
33
appDir: true,
4-
transpileModules: ['ui'],
54
},
65
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export default function Root({ children }: { children: React.ReactNode }) {
22
return (
33
<html>
4-
<head></head>
5-
<body>{children}</body>
4+
<body>
5+
<header>top bar</header>
6+
{children}
7+
</body>
68
</html>
79
)
810
}

0 commit comments

Comments
 (0)