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:
parent
e66c5151bb
commit
805d646822
|
|
@ -288,8 +288,14 @@ function processFile(filePath) {
|
||||||
if (anchor) {
|
if (anchor) {
|
||||||
const targetContent = fs.readFileSync(targetFile, 'utf-8');
|
const targetContent = fs.readFileSync(targetFile, 'utf-8');
|
||||||
const anchors = extractAnchors(targetContent);
|
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({
|
issues.push({
|
||||||
type: 'broken-anchor',
|
type: 'broken-anchor',
|
||||||
linkText,
|
linkText,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue