fixing multiple doctype injections in single file (#5035)

* fixing multiple doctype injections in single file

* adding changeset

Co-authored-by: C5341616 <C5341616@sap.com>
This commit is contained in:
Daniel 2022-10-10 15:02:20 +02:00 committed by GitHub
parent b1964e9e1b
commit d7bfb144ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
preventing multiple doctype injection into html documents

View file

@ -30,6 +30,7 @@ async function iterableToHTMLBytes(
for await (const chunk of iterable) {
if (isHTMLString(chunk)) {
if (i === 0) {
i++;
if (!/<!doctype html/i.test(String(chunk))) {
parts.append('<!DOCTYPE html>\n', result);
if (onDocTypeInjection) {