From ad5dc4c4698356e83a9f06eb5fbd337d9cb1317e 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/39429 Reviewed-By: Tobias Nießen Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Zeyu Yang --- 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]}`); }