2
0

🐛 (settings) Allow meta tags in head element

This commit is contained in:
Baptiste Arnaud
2022-11-04 07:47:17 +01:00
parent c62e20f81a
commit ad9be92255
2 changed files with 12 additions and 1 deletions

View File

@ -47,7 +47,12 @@ export const getServerSideProps: GetServerSideProps = async (
url: `https://${forwardedHost ?? host}${pathname}`,
customHeadCode:
isDefined(headCode) && headCode !== ''
? sanitizeHtml(headCode, { allowedTags: ['script', 'meta'] })
? sanitizeHtml(headCode, {
allowedTags: ['script', 'meta'],
allowedAttributes: {
meta: ['name', 'content'],
},
})
: null,
},
}

View File

@ -17,6 +17,7 @@ test('Should correctly parse metadata', async ({ page }) => {
title: 'Custom title',
favIconUrl: 'https://www.baptistearno.com/favicon.png',
imageUrl: 'https://www.baptistearno.com/images/site-preview.png',
customHeadCode: '<meta name="author" content="John Doe">',
}
await createTypebots([
{
@ -50,6 +51,11 @@ test('Should correctly parse metadata', async ({ page }) => {
(document.querySelector('link[rel="icon"]') as any).getAttribute('href')
)
).toBe(customMetadata.favIconUrl)
expect(
await page.evaluate(
() => (document.querySelector('meta[name="author"]') as any).content
)
).toBe('John Doe')
await expect(
typebotViewer(page).locator(
`input[placeholder="${defaultTextInputOptions.labels.placeholder}"]`