Skip to content

Commit f3906e5

Browse files
cristianocclaude
andcommitted
Fix link checker false positives for SVG diagrams in blog post
The reactive analysis blog post references SVG diagrams via absolute paths (/blog/reactive-analysis/*.svg). The link validator resolves these relative to the markdown file and reports them as missing. Check whether warned-about files exist in public/ before reporting, since Vite serves public/ assets at root. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 59fd270 commit f3906e5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

scripts/test-hrefs.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,27 @@ for (const file of files) {
2626

2727
const warningMessage = log.replace(file, "");
2828

29+
// Skip warnings about files that exist in public/ (served at root by Vite)
30+
const missingFileMatches = [
31+
...warningMessage.matchAll(/`\.\.\/\.\.\/(.*?)`/g),
32+
];
33+
let allMissingExistInPublic = false;
34+
if (missingFileMatches.length > 0) {
35+
allMissingExistInPublic = (
36+
await Promise.all(
37+
missingFileMatches.map(([, p]) =>
38+
fs.access("public/" + p).then(
39+
() => true,
40+
() => false,
41+
),
42+
),
43+
)
44+
).every(Boolean);
45+
}
46+
2947
if (
3048
log &&
49+
!allMissingExistInPublic &&
3150
!warningMessage.includes("api/") &&
3251
// When running on CI it fails to ignore the link directly to the blog root
3352
// https://github.com/rescript-lang/rescript-lang.org/actions/runs/19520461368/job/55882556586?pr=1115#step:6:338

0 commit comments

Comments
 (0)