Skip to content

Commit

Permalink
fix: ensure canonical URL pathname consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
ccbikai committed Nov 9, 2024
1 parent 7da142a commit 1d22719
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/layouts/base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const { channel } = Astro.props
const locale = getEnv(import.meta.env, Astro, 'LOCALE')
const seo = channel?.seo
const canonical = SITE_URL.startsWith('http')
? new URL(SITE_URL).origin + Astro.url.pathname
: Astro.url.origin + Astro.url.pathname
const reqPathname = Astro.url.pathname.replace(/\/$/, '')
const canonical = SITE_URL.startsWith('http') ? new URL(SITE_URL).origin + reqPathname : Astro.url.origin + reqPathname
const { origin, pathname } = new URL(canonical)
const twitter = getEnv(import.meta.env, Astro, 'TWITTER')
Expand Down

0 comments on commit 1d22719

Please sign in to comment.