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:
parent
b1964e9e1b
commit
d7bfb144ba
2 changed files with 6 additions and 0 deletions
5
.changeset/chilly-carrots-think.md
Normal file
5
.changeset/chilly-carrots-think.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
preventing multiple doctype injection into html documents
|
|
@ -30,6 +30,7 @@ async function iterableToHTMLBytes(
|
||||||
for await (const chunk of iterable) {
|
for await (const chunk of iterable) {
|
||||||
if (isHTMLString(chunk)) {
|
if (isHTMLString(chunk)) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
|
i++;
|
||||||
if (!/<!doctype html/i.test(String(chunk))) {
|
if (!/<!doctype html/i.test(String(chunk))) {
|
||||||
parts.append('<!DOCTYPE html>\n', result);
|
parts.append('<!DOCTYPE html>\n', result);
|
||||||
if (onDocTypeInjection) {
|
if (onDocTypeInjection) {
|
||||||
|
|
Loading…
Reference in a new issue