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 <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
Trott authored and targos committed Jan 14, 2022
1 parent 4a369d0 commit 4a57d47
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 4a57d47

Please sign in to comment.