Skip to content

Commit f635b92

Browse files
authored
fix(unhead): multiword attributes in template (#568)
1 parent 97bcb23 commit f635b92

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/unhead/src/server/util/extractUnheadInputFromHtml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { SerializableHead } from '../../types'
22

3-
const Attrs = /(\w+)(?:=["']([^"']*)["'])?/g
3+
const Attrs = /(\w+-?\w+)(?:=["']([^"']*)["'])?/g
44
const HtmlTag = /<html[^>]*>/
55
const BodyTag = /<body[^>]*>/
66
const HeadContent = /<head[^>]*>(.*?)<\/head>/s

packages/unhead/test/unit/server/ssr.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,31 @@ describe('ssr', () => {
132132
`)
133133
})
134134

135+
it('multiword attributes in html template', async () => {
136+
const head = createServerHeadWithContext()
137+
138+
expect(await transformHtmlTemplate(head, `
139+
<html>
140+
<head>
141+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
142+
</head>
143+
<body>
144+
<!--app-html-->
145+
</body>
146+
</html>
147+
`)).toMatchInlineSnapshot(`
148+
"
149+
<html>
150+
<head>
151+
<meta http-equiv="X-UA-Compatible" content="IE=edge"></head>
152+
<body>
153+
<!--app-html-->
154+
</body>
155+
</html>
156+
"
157+
`)
158+
})
159+
135160
it('useSeoMeta', async () => {
136161
const head = createServerHeadWithContext()
137162

0 commit comments

Comments
 (0)