Skip to content

Commit abeec05

Browse files
AFDocs fixes: avoid redirect-behavior false positive in anchor copy handler (#130)
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 <oz-agent@warp.dev>
1 parent fb574ac commit abeec05

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/components/CustomHead.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ const fontsHref =
109109
history.pushState(null, '', url);
110110
showCopiedFeedback(anchor);
111111
} catch {
112-
window.location.href = href;
112+
// Navigate to the anchor fragment without using href-based
113+
// navigation, which the afdocs redirect-behavior check
114+
// misclassifies as a JS redirect when scanned in inline scripts.
115+
window.location.hash = url.hash;
113116
}
114117
});
115118
</script>

0 commit comments

Comments
 (0)