Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit fe3fc34

Browse files
authored
fix(head): case http-equiv correctly (#7190)
1 parent d31e1f0 commit fe3fc34

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

packages/nuxt/src/head/runtime/components.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,17 @@ export const Meta = defineComponent({
197197
httpEquiv: String as PropType<HTTPEquiv>,
198198
name: String
199199
},
200-
setup: setupForUseMeta(meta => ({
201-
meta: [meta]
202-
}))
200+
setup: setupForUseMeta((props) => {
201+
const meta = { ...props }
202+
// fix casing for http-equiv
203+
if (meta.httpEquiv) {
204+
meta['http-equiv'] = meta.httpEquiv
205+
delete meta.httpEquiv
206+
}
207+
return {
208+
meta: [meta]
209+
}
210+
})
203211
})
204212

205213
// <style>

test/basic.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ describe('head tags', () => {
165165
expect(indexHtml).toContain('<title>Basic fixture</title>')
166166
})
167167

168+
it('should render http-equiv correctly', async () => {
169+
const html = await $fetch('/head')
170+
// http-equiv should be rendered kebab case
171+
expect(html).toContain('<meta content="default-src https" http-equiv="content-security-policy">')
172+
})
173+
168174
// TODO: Doesn't adds header in test environment
169175
// it.todo('should render stylesheet link tag (SPA mode)', async () => {
170176
// const html = await $fetch('/head', { headers: { 'x-nuxt-no-ssr': '1' } })

test/fixtures/basic/pages/head.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
<div>
3636
<Head>
3737
<Title>Using a dynamic component</Title>
38+
<Meta http-equiv="content-security-policy" content="default-src https" />
3839
</Head>
3940
</div>
4041
</template>

0 commit comments

Comments
 (0)