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

Commit

Permalink
fix(head): case http-equiv correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Sep 3, 2022
1 parent abd5dc5 commit 29fdc5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/nuxt/src/head/runtime/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,17 @@ export const Meta = defineComponent({
httpEquiv: String as PropType<HTTPEquiv>,
name: String
},
setup: setupForUseMeta(meta => ({
meta: [meta]
}))
setup: setupForUseMeta((props) => {
const meta = { ...props }
// fix casing for http-equiv
if (meta.httpEquiv) {
meta['http-equiv'] = meta.httpEquiv
delete meta.httpEquiv
}
return {
meta: [meta]
}
})
})

// <style>
Expand Down
6 changes: 6 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ describe('head tags', () => {
expect(indexHtml).toContain('<title>Basic fixture</title>')
})

it('should render http-equiv correctly', async () => {
const html = await $fetch('/head')
// http-equiv should be rendered kebab case
expect(html).toContain('<meta content="default-src https" http-equiv="content-security-policy">')
})

// TODO: Doesn't adds header in test environment
// it.todo('should render stylesheet link tag (SPA mode)', async () => {
// const html = await $fetch('/head', { headers: { 'x-nuxt-no-ssr': '1' } })
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/basic/pages/head.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default {
<div>
<Head>
<Title>Using a dynamic component</Title>
<Meta http-equiv="content-security-policy" content="default-src https" />
</Head>
</div>
</template>

0 comments on commit 29fdc5f

Please sign in to comment.