From 108e8a28428f7733b7e5b6f663eda1344d7a21b1 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 20 Nov 2023 15:56:32 +0100 Subject: [PATCH 1/2] fix(prerender): filter encoded links starting with `#` --- src/prerender.ts | 1 + test/fixture/routes/prerender.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/prerender.ts b/src/prerender.ts index f15f867be0..cbd692ed1c 100644 --- a/src/prerender.ts +++ b/src/prerender.ts @@ -384,6 +384,7 @@ function extractLinks( _links.push( ...[...html.matchAll(LINK_REGEX)] .map((m) => escapeHtml(m[1])) + .filter((m) => !decodeURIComponent(m).startsWith("#")) .filter((link) => allowedExtensions.has(getExtension(link))) ); } diff --git a/test/fixture/routes/prerender.ts b/test/fixture/routes/prerender.ts index 9529ae609f..b76ee0abb8 100644 --- a/test/fixture/routes/prerender.ts +++ b/test/fixture/routes/prerender.ts @@ -39,6 +39,9 @@ ${links.map((link) => `
  • ${link}
  • `).join("\n")} x-href attr <a href="/500</a> + + + `; }); From 51429c72e1f82d66052335c696bc6dd0e48b9ba1 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 20 Nov 2023 15:58:15 +0100 Subject: [PATCH 2/2] simplify ficture --- test/fixture/routes/prerender.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/fixture/routes/prerender.ts b/test/fixture/routes/prerender.ts index b76ee0abb8..a4a4429bc2 100644 --- a/test/fixture/routes/prerender.ts +++ b/test/fixture/routes/prerender.ts @@ -39,9 +39,8 @@ ${links.map((link) => `
  • ${link}
  • `).join("\n")} x-href attr <a href="/500</a> - - - #a + #b `; });