From c11630328dfdee05a8f52dccf752dfcebe8d5152 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 3 Oct 2022 14:38:06 +0100 Subject: [PATCH] ci(crawl): ignore `` links without hrefs (#7925) Co-authored-by: Alexander Lichter --- scripts/crawl.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/crawl.mjs b/scripts/crawl.mjs index 5a2c6a84f5..3b2a1e76b9 100755 --- a/scripts/crawl.mjs +++ b/scripts/crawl.mjs @@ -32,6 +32,13 @@ const erroredUrls = new Set() * @param {string | undefined} referrer The referring page */ function queue (path, referrer) { + if (!path) { + const message = chalk.red(`${chalk.bold('✗')} ${referrer} linked to empty href`) + if (isCI) { actions.error(message) } + logger.log(message) + return + } + if (urlsToOmit.some(url => path.startsWith(url))) { return } const { pathname, origin } = new URL(path, referrer) @@ -80,7 +87,11 @@ const crawler = new Crawler({ return done() } - $('a:not([href*=mailto])').each((_, el) => 'attribs' in el && queue(el.attribs.href, uri)) + $('a:not([href*=mailto]):not([href*=tel])').each((_, el) => { + if ('attribs' in el && 'href' in el.attribs) { + queue(el.attribs.href, uri) + } + }) logger.success(chalk.green(uri)) logger.debug(uri, `[${crawler.queueSize} / ${urls.size}]`)