Skip to content

Commit

Permalink
Ooooooooh this should fix it 🤦‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
benface committed Jan 28, 2025
1 parent efc4937 commit b180e09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions website/src/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ function MyApp({ Component, router, pageProps }: AppProps) {
if (matches?.length) {
const path = matches[1] ? (matches[1].startsWith('/') ? matches[1] : `/${matches[1]}`) : '/'
const basePath = process.env.BASE_PATH ?? ''
if (path === basePath || path.startsWith(`${basePath}/`)) {
// If the link is a root-relative URL (or an absolute but internal URL), ensure it is relative to the base path
href = path.substring(basePath.length) || '/'
const pathIncludesBasePath = path === basePath || path.startsWith(`${basePath}/`)
if (href.startsWith('/') || pathIncludesBasePath) {
// If the link is a root-relative URL or an absolute but internal URL, ensure it is relative to the base path
href = pathIncludesBasePath ? path.substring(basePath.length) : path
// Also ensure the link includes a locale
const { locale: pathLocale, pathWithoutLocale } = extractLocaleFromPath(href, supportedLocales)
href = `/${pathLocale ?? locale ?? defaultLocale}${pathWithoutLocale}`
Expand Down

0 comments on commit b180e09

Please sign in to comment.