Skip to content

Commit 088fa34

Browse files
authored
fix(prerender): filter encoded links starting with # (#1936)
1 parent cb7900c commit 088fa34

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/prerender.ts

+1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ function extractLinks(
384384
_links.push(
385385
...[...html.matchAll(LINK_REGEX)]
386386
.map((m) => escapeHtml(m[1]))
387+
.filter((m) => !decodeURIComponent(m).startsWith("#"))
387388
.filter((link) => allowedExtensions.has(getExtension(link)))
388389
);
389390
}

test/fixture/routes/prerender.ts

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ ${links.map((link) => ` <li><a href="${link}">${link}</a></li>`).join("\n")}
3939
<link rel="icon" href="data:image/png;base64,aaa//bbbbbb/ccc">
4040
<a x-href="/500?x-href">x-href attr</a>
4141
&lt;a href=&quot;/500&lt;/a&gt;
42+
<a href='#a'>#a</a>
43+
<a href='%23b'>#b</a>
4244
</body>
4345
</html>`;
4446
});

0 commit comments

Comments
 (0)