Skip to content

Commit

Permalink
Fix server html insertion target (#42591)
Browse files Browse the repository at this point in the history
Fixes #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`
  • Loading branch information
huozhi committed Nov 7, 2022
1 parent b1932b0 commit 01a1a7f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/next/server/node-web-streams-helper.ts
Expand Up @@ -173,7 +173,7 @@ function createHeadInsertionTransformStream(
freezing = true
} else {
const content = decodeText(chunk)
const index = content.indexOf('</head')
const index = content.indexOf('</head>')
if (index !== -1) {
const insertedHeadContent =
content.slice(0, index) + insertion + content.slice(index)
Expand Down
1 change: 1 addition & 0 deletions test/.gitignore
@@ -1 +1,2 @@
!node_modules
.vscode
1 change: 0 additions & 1 deletion test/e2e/app-dir/app-alias/next.config.js
@@ -1,6 +1,5 @@
module.exports = {
experimental: {
appDir: true,
transpileModules: ['ui'],
},
}
6 changes: 4 additions & 2 deletions test/e2e/app-dir/app-alias/src/app/layout.tsx
@@ -1,8 +1,10 @@
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html>
<head></head>
<body>{children}</body>
<body>
<header>top bar</header>
{children}
</body>
</html>
)
}

0 comments on commit 01a1a7f

Please sign in to comment.