fix(docs): handle non-ASCII anchors in link validator

Anchor validation failed for links containing accented characters
(e.g. ./customize-bmad.md#dépannage) because the raw anchor didn't
match the slugified version produced by extractAnchors.

Normalize anchors through decodeURIComponent + headingToAnchor before
comparing, and guard against malformed URI components.
This commit is contained in:
Emmanuel Atsé 2026-05-21 14:53:19 +02:00
parent e66c5151bb
commit 805d646822
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -288,8 +288,14 @@ function processFile(filePath) {
if (anchor) {
const targetContent = fs.readFileSync(targetFile, 'utf-8');
const anchors = extractAnchors(targetContent);
let normalizedAnchor;
try {
normalizedAnchor = headingToAnchor(decodeURIComponent(anchor));
} catch {
normalizedAnchor = headingToAnchor(anchor);
}
if (!anchors.has(anchor)) {
if (!anchors.has(anchor) && !anchors.has(normalizedAnchor)) {
issues.push({
type: 'broken-anchor',
linkText,