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}`, url: `https://${forwardedHost ?? host}${pathname}`,
customHeadCode: customHeadCode:
isDefined(headCode) && headCode !== '' isDefined(headCode) && headCode !== ''
? sanitizeHtml(headCode, { allowedTags: ['script', 'meta'] }) ? sanitizeHtml(headCode, {
allowedTags: ['script', 'meta'],
allowedAttributes: {
meta: ['name', 'content'],
},
})
: null, : null,
}, },
} }

View File

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