fix(i18n): fix get path for external links (#665)

This commit is contained in:
Shintaro Jokagi 2025-06-06 13:29:15 +12:00 committed by GitHub
parent 1b129bbe6c
commit 350edb5b73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,6 +16,11 @@ export type Locale = (typeof locales)[number]
export const getPath = export const getPath =
(locale?: Locale): ((arg0: string) => string) => (locale?: Locale): ((arg0: string) => string) =>
(path: string) => { (path: string) => {
// Return external URLs unchanged
if (path.startsWith('http://') || path.startsWith('https://')) {
return path
}
// Check if path already contains any locale prefix // Check if path already contains any locale prefix
const existingLocale = locales.find(l => path.startsWith(`/${l}/`)) const existingLocale = locales.find(l => path.startsWith(`/${l}/`))