From c9d574343d04ad1405256c5ae04cd04919cad347 Mon Sep 17 00:00:00 2001 From: Steve Dodier-Lazaro Date: Tue, 24 Dec 2024 00:55:54 +0100 Subject: [PATCH] Addon-docs: URL encode anchor IDs when clicking in ToC --- code/lib/blocks/src/components/TableOfContents.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/blocks/src/components/TableOfContents.tsx b/code/lib/blocks/src/components/TableOfContents.tsx index 572286373fa..c4cdf833e02 100644 --- a/code/lib/blocks/src/components/TableOfContents.tsx +++ b/code/lib/blocks/src/components/TableOfContents.tsx @@ -163,7 +163,7 @@ export const TableOfContents = ({ e.preventDefault(); if (e.currentTarget instanceof HTMLAnchorElement) { const [, headerId] = e.currentTarget.href.split('#'); - channel.emit(NAVIGATE_URL, `#${headerId}`); + channel.emit(NAVIGATE_URL, `#${encodeURIComponent(headerId)}`); } }, ...unsafeTocbotOptions,