Skip to content

Commit 366f5fb

Browse files
Ensure script-created headings are lowercase
1 parent 3bf344a commit 366f5fb

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

assets-src/js/main/heading-anchors.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ let headingAnchors = function () {
5252
// - Remove leading/trailing spaces
5353
// - Use RegEx to remove invalid characters but keep all Unicode letters/numbers
5454
// - Use RegEx to replace spaces with hyphens
55+
// - convert to lowercase as per URL policy
5556
anchorHref = heading.textContent
5657
.trim()
5758
.replace(/[^\p{L}\p{N}\s-]/gu, '')
58-
.replace(/\s+/g, '-');
59+
.replace(/\s+/g, '-')
60+
.toLowerCase();
5961
heading.id = anchorHref;
6062
}
6163

public/dist/assets/js/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,8 @@ let headingAnchors = function () {
958958
// - Remove leading/trailing spaces
959959
// - Use RegEx to remove invalid characters but keep all Unicode letters/numbers
960960
// - Use RegEx to replace spaces with hyphens
961-
anchorHref = heading.textContent.trim().replace(/[^\p{L}\p{N}\s-]/gu, '').replace(/\s+/g, '-');
961+
// - convert to lowercase as per URL policy
962+
anchorHref = heading.textContent.trim().replace(/[^\p{L}\p{N}\s-]/gu, '').replace(/\s+/g, '-').toLowerCase();
962963
heading.id = anchorHref;
963964
}
964965
anchor.setAttribute('href', '#' + anchorHref);

0 commit comments

Comments
 (0)