Skip to content

Open source alternative to Semrush and Ahrefs

Stop reporting Cloudflare email-protection links as broken (#1068)

Ben Senescu3cfa13e213e9
diff --git a/src/server/lib/audit/url-utils.test.ts b/src/server/lib/audit/url-utils.test.ts
index e4d02da3..40fb919f 100644
--- a/src/server/lib/audit/url-utils.test.ts
+++ b/src/server/lib/audit/url-utils.test.ts
@@ -77,6 +77,7 @@ describe("isAuditablePageUrl", () => {
["https://example.com/discount/SAVE10?redirect=%2F", "shopify", false],
["https://example.com/discount/SAVE10", undefined, true],
["https://example.com/en/collections/all?page=2", "shopify", true],
+ ["https://example.com/cdn-cgi/l/email-protection", undefined, false],
] as const)("isAuditablePageUrl(%s, %s) is %s", (url, platform, expected) => {
expect(isAuditablePageUrl(url, platform)).toBe(expected);
});
diff --git a/src/server/lib/audit/url-utils.ts b/src/server/lib/audit/url-utils.ts
index 6fd0226f..aa9b64ca 100644
--- a/src/server/lib/audit/url-utils.ts
+++ b/src/server/lib/audit/url-utils.ts
@@ -176,6 +176,11 @@ const SHOPIFY_NON_PAGE_PATHS =
* themes link every gallery photo on the storefront origin, and one store's
* audit spent 1,986 of its 2,608 fetches on them. Unknown extensions pass.
* The trade: a broken link to such a file is no longer reported.
+ *
+ * Cloudflare's reserved `/cdn-cgi/` paths are skipped too. Its email
+ * obfuscation rewrites every mailto link to `/cdn-cgi/l/email-protection`,
+ * which answers crawlers with a 404, so a site with an email in its footer
+ * got one false broken link per page.
*/
export function isAuditablePageUrl(
url: string,
@@ -188,6 +193,7 @@ export function isAuditablePageUrl(
return false;
}
if (NON_DOCUMENT_EXTENSIONS.test(parsed.pathname)) return false;
+ if (parsed.pathname.startsWith("/cdn-cgi/")) return false;
return !(
sitePlatform === "shopify" && SHOPIFY_NON_PAGE_PATHS.test(parsed.pathname)
);