Skip to content

Commit 407838c

Browse files
fix: remove invalid characters from result.html anchor links
Links to result.html failed when maintainer names contained spaces or special characters like '&' (e.g., "klaernie & KristjanESPERANTO"). The '&' character is not valid in CSS selectors, causing querySelector to throw "not a valid selector" errors. URL-encoded spaces (%20) also didn't match the dash-converted anchor IDs. Now both script.js (link generation) and result.html (anchor creation) use the same sanitization: replace spaces with dashes and remove '&' and '/' characters.
1 parent f6e240c commit 407838c

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

website/result.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
function addHeadingAnchors() {
3434
const headings = document.querySelectorAll("h1, h2, h3, h4");
3535
headings.forEach((heading) => {
36-
const anchorId = heading.textContent.replaceAll(" ", "-");
36+
const anchorId = heading.textContent
37+
.replaceAll(" ", "-")
38+
.replaceAll("&", "")
39+
.replaceAll("/", "");
3740
const anchor = document.createElement("a");
3841
anchor.id = anchorId;
3942
anchor.href = "#" + anchorId;

website/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function createCard(moduleData) {
133133
}
134134

135135
if (moduleData.issues) {
136-
const url = `result.html#${moduleData.name}-by-${moduleData.maintainer}`;
136+
const url = `result.html#${moduleData.name}-by-${moduleData.maintainer.replaceAll(" ", "-").replaceAll("&", "").replaceAll("/", "")}`;
137137
card.querySelector(".info .container.issues .text").href = url;
138138
}
139139
else {

0 commit comments

Comments
 (0)