From 87aa1f633de145518cac8d5e91398987810125a8 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 0000000000..5afb9524f1 --- /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 52b6b006e1..f8a084d928 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/giu; +const commentRegex = /