From cbef4649d36ae75b321273f06a610b92477ccb56 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 18 Jul 2021 07:04:00 -0700 Subject: [PATCH] tools: make internal link checker more robust 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: https://github.com/nodejs/node/pull/39426 Refs: https://github.com/nodejs/node/pull/39425 --- tools/doc/allhtml.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/doc/allhtml.mjs b/tools/doc/allhtml.mjs index 54a51dd6316010..905ea5d3dd6c6f 100644 --- a/tools/doc/allhtml.mjs +++ b/tools/doc/allhtml.mjs @@ -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]}`); }