From 0bab357c48605462ead893cfae843ef159d16e82 Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Wed, 2 Nov 2022 01:38:45 +0530 Subject: [PATCH] fix: consider trailing slashes when calculating current path in blog example (#5272) --- examples/blog/src/components/HeaderLink.astro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/blog/src/components/HeaderLink.astro b/examples/blog/src/components/HeaderLink.astro index d82155c62..e8e2e103b 100644 --- a/examples/blog/src/components/HeaderLink.astro +++ b/examples/blog/src/components/HeaderLink.astro @@ -2,7 +2,9 @@ export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {} const { href, class: className, ...props } = Astro.props; -const isActive = href === Astro.url.pathname.replace(/\/$/, ''); + +const { pathname } = Astro.url; +const isActive = href === pathname || href === pathname.replace(/\/$/, ''); ---