fix(cli): narrow blocked page titles

This commit is contained in:
Miguel Ángel
2026-07-31 20:30:07 +00:00
parent dfc60797a2
commit b38e907404
2 changed files with 22 additions and 2 deletions
@@ -70,6 +70,26 @@ describe("detectBlockedPage", () => {
hasChallengeElement: true,
},
},
{
label: "a minimal photography page named Forbidden Fruit Photography",
evidence: {
httpStatus: 200,
title: "Forbidden Fruit Photography",
textLength: 40,
bodyChildCount: 4,
hasChallengeElement: false,
},
},
{
label: "a minimal photo essay named Attention Required",
evidence: {
httpStatus: 200,
title: "Attention Required: A Photo Essay",
textLength: 60,
bodyChildCount: 5,
hasChallengeElement: false,
},
},
])("allows $label", ({ evidence }) => {
expect(detectBlockedPage(evidence)).toBeUndefined();
});
@@ -16,8 +16,8 @@ export function detectBlockedPage(evidence: PageLoadEvidence): string | undefine
const hasBlockedStatus =
evidence.httpStatus === 401 || evidence.httpStatus === 403 || evidence.httpStatus === 429;
const hasBlockedTitle =
/^(?:error\s*)?(?:401|403|429)(?:\s*[-:—]\s*|\s+)|forbidden|access denied|attention required|just a moment/i.test(
evidence.title,
/^(?:(?:error\s*)?(?:401|403|429)(?:\s*(?:[-:—]\s*)?(?:forbidden|unauthorized|access denied|too many requests))?|forbidden|access denied|attention required|just a moment(?:\.{3})?)(?:\s*[|—-]\s*(?:cloudflare|sucuri website firewall))?$/i.test(
evidence.title.trim(),
);
if (!isMinimalDom || (!evidence.hasChallengeElement && !hasBlockedStatus && !hasBlockedTitle)) {