Skip to content

Commit

Permalink
tools: replace while+exec() with matchAll()
Browse files Browse the repository at this point in the history
PR-URL: #41406
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
Trott authored and danielleadams committed Feb 1, 2022
1 parent 91c3e28 commit 62450d3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/doc/allhtml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ fs.writeFileSync(new URL('./all.html', source), all, 'utf8');
// Validate all hrefs have a target.
const ids = new Set();
const idRe = / id="([^"]+)"/g;
let match;
while (match = idRe.exec(all)) {
const idMatches = all.matchAll(idRe);
for (const match of idMatches) {
ids.add(match[1]);
}

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

0 comments on commit 62450d3

Please sign in to comment.