From 8eb0bd659407877688aea881e91552c796fa15d3 Mon Sep 17 00:00:00 2001 From: rachaelrenk Date: Fri, 22 May 2026 08:08:12 +0000 Subject: [PATCH 1/2] AFDocs fixes: avoid redirect-behavior false positive in anchor copy handler Replace `window.location.href = href` with `window.location.hash = url.hash` in the heading anchor click handler. The old pattern triggered the afdocs `redirect-behavior` check, which heuristically scans the first 10 KB of HTML for `location.href =` assignments and classifies any match as a JavaScript redirect. Since anchor links are always fragment-only, `location.hash` is functionally equivalent and avoids the false positive. Co-Authored-By: Oz --- src/components/CustomHead.astro | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/CustomHead.astro b/src/components/CustomHead.astro index 8b454e8b..7187a61d 100644 --- a/src/components/CustomHead.astro +++ b/src/components/CustomHead.astro @@ -109,7 +109,11 @@ const fontsHref = history.pushState(null, '', url); showCopiedFeedback(anchor); } catch { - window.location.href = href; + // Navigate to the anchor fragment. Avoids `window.location.href = …` + // which the afdocs redirect-behavior check misclassifies as a JS + // redirect (it heuristically scans for location.href assignments in + // the first 10 KB of HTML). + window.location.hash = url.hash; } }); From 47d6dd978a3bfb614670a75ec4d01e2d05d6d301 Mon Sep 17 00:00:00 2001 From: Rachael Rose Renk <91027132+rachaelrenk@users.noreply.github.com> Date: Tue, 26 May 2026 12:39:57 -0600 Subject: [PATCH 2/2] Update src/components/CustomHead.astro Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com> --- src/components/CustomHead.astro | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/CustomHead.astro b/src/components/CustomHead.astro index 7187a61d..e8bd21f1 100644 --- a/src/components/CustomHead.astro +++ b/src/components/CustomHead.astro @@ -109,10 +109,9 @@ const fontsHref = history.pushState(null, '', url); showCopiedFeedback(anchor); } catch { - // Navigate to the anchor fragment. Avoids `window.location.href = …` - // which the afdocs redirect-behavior check misclassifies as a JS - // redirect (it heuristically scans for location.href assignments in - // the first 10 KB of HTML). + // Navigate to the anchor fragment without using href-based + // navigation, which the afdocs redirect-behavior check + // misclassifies as a JS redirect when scanned in inline scripts. window.location.hash = url.hash; } });