From 8eb0bd659407877688aea881e91552c796fa15d3 Mon Sep 17 00:00:00 2001 From: rachaelrenk Date: Fri, 22 May 2026 08:08:12 +0000 Subject: [PATCH] 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 8b454e8..7187a61 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; } });