From ed1f3ec22b5b03d314e545a818513cf4283adecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Gro=C3=9F?= Date: Sat, 20 Jul 2024 11:13:54 +0200 Subject: [PATCH] server-islands: only encode ETAGO delimiter & opening HTML comment --- .changeset/fifty-socks-end.md | 5 +++++ .../src/runtime/server/render/server-islands.ts | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .changeset/fifty-socks-end.md diff --git a/.changeset/fifty-socks-end.md b/.changeset/fifty-socks-end.md new file mode 100644 index 0000000000000..5afb9524f1d51 --- /dev/null +++ b/.changeset/fifty-socks-end.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Only escape the script tag ETAGO delimiter and opening HTML comment syntax in server islands to reduce encoding work. diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts index 52b6b006e1935..a3821b1034c21 100644 --- a/packages/astro/src/runtime/server/render/server-islands.ts +++ b/packages/astro/src/runtime/server/render/server-islands.ts @@ -14,13 +14,19 @@ export function containsServerDirective(props: Record) { return 'server:component-directive' in props; } +const scriptRegex = /<\/script/gui; +const commentRegex = /