mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: replace while+exec() with matchAll()
PR-URL: https://github.com/nodejs/node/pull/41406 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
@@ -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]}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user