Skip to content

Commit

Permalink
tools: make internal link checker more robust
Browse files Browse the repository at this point in the history
The internal link checker was missing some broken links because it was
being too restrictive about the characters it accepted as part of a link
hash. Accept anything that isn't a terminating quotation mark.

Refs: #39426
Refs: #39425

PR-URL: #39429
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
  • Loading branch information
Trott authored and nodejs-github-bot committed Jul 20, 2021
1 parent e83c8ae commit ad5dc4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/doc/allhtml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ fs.writeFileSync(new URL('./all.html', source), all, 'utf8');

// Validate all hrefs have a target.
const ids = new Set();
const idRe = / id="(\w+)"/g;
const idRe = / id="([^"]+)"/g;
let match;
while (match = idRe.exec(all)) {
ids.add(match[1]);
}

const hrefRe = / href="#(\w+)"/g;
const hrefRe = / href="#([^"]+)"/g;
while (match = hrefRe.exec(all)) {
if (!ids.has(match[1])) throw new Error(`link not found: ${match[1]}`);
}

0 comments on commit ad5dc4c

Please sign in to comment.