From fc939b27295ecb75e3f9fd3efcf562ca43186c0a Mon Sep 17 00:00:00 2001 From: Joshua Hemphill Date: Wed, 1 Jun 2022 11:18:02 -0700 Subject: [PATCH] fix: :bug: html tag location in head closes #7 --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index b8414bd..724fb20 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,6 +26,10 @@ class HtmlTag implements HtmlTagDescriptor { } } +class HtmlHeadTag extends HtmlTag { + injectTo = 'head' as const; +} + export type ViteCspPluginOptions = typeof DEFAULT_OPTIONS; type ViteCspPluginOpts = Partial @@ -243,7 +247,7 @@ function createViteCspPlugin(...opts: ([PolicyOptions, ViteCspPluginOpts] | [Vit if (inject) { return Object.entries(parsedHeaders) .filter(([k]) => injectReporting || !k.includes('Report')) - .map(([k, v]) => new HtmlTag('meta', { + .map(([k, v]) => new HtmlHeadTag('meta', { 'http-equiv': k, content: v, }));