@@ -28,6 +28,7 @@ import { DataResearch } from 'src/pages/DataResearch/DataResearch'
2828import { ErrorPage } from 'src/pages/ErrorPage'
2929import GapsPatternsPage from 'src/pages/gapsPatterns'
3030import VelocityHeatmapPage from 'src/pages/velocityHeatmap'
31+ import { LegacyLangRedirect } from './LegacyLangRedirect'
3132import { MainRoute } from './MainRoute'
3233
3334const HomePage = lazy ( ( ) => import ( '../pages/homepage/HomePage' ) )
@@ -165,35 +166,37 @@ const RedirectToHomepage = <Navigate to={routesList[0].path} replace />
165166
166167export const getRoutesList = ( ) => {
167168 return (
168- < Route path = "/:lang?" >
169- < Route element = { < MainRoute /> } >
170- { routesList . map ( ( { path, element } ) => (
171- < Route
172- key = { path }
173- path = { path === '/' ? undefined : path . replace ( / ^ \/ / , '' ) }
174- index = { path === '/' }
175- element = { element }
176- ErrorBoundary = { ErrorPage }
177- />
178- ) ) }
169+ < Route element = { < MainRoute /> } >
170+ { routesList . map ( ( { path, element } ) => (
179171 < Route
180- path = "profile/:gtfsRideGtfsRouteId"
181- element = { < Profile /> }
172+ key = { path }
173+ path = { path === '/' ? undefined : path . replace ( / ^ \/ / , '' ) }
174+ index = { path === '/' }
175+ element = { element }
182176 ErrorBoundary = { ErrorPage }
183- loader = { async ( { params } ) => {
184- try {
185- const route = await getRouteById ( params ?. gtfsRideGtfsRouteId )
186- return { route }
187- } catch ( error ) {
188- return {
189- route : null ,
190- message : ( error as Error ) . message ,
191- }
192- }
193- } }
194177 />
195- < Route path = "*" element = { RedirectToHomepage } key = "back" />
196- </ Route >
178+ ) ) }
179+ < Route
180+ path = "profile/:gtfsRideGtfsRouteId"
181+ element = { < Profile /> }
182+ ErrorBoundary = { ErrorPage }
183+ loader = { async ( { params } ) => {
184+ try {
185+ const route = await getRouteById ( params ?. gtfsRideGtfsRouteId )
186+ return { route }
187+ } catch ( error ) {
188+ return {
189+ route : null ,
190+ message : ( error as Error ) . message ,
191+ }
192+ }
193+ } }
194+ />
195+ { /* Backward-compat: old links carried a language prefix (/he, /en, /ru, /ar).
196+ Strip it, apply the language, and redirect to the clean path.
197+ Remove this route (and LegacyLangRedirect) once such links have aged out. */ }
198+ < Route path = ":lang/*" element = { < LegacyLangRedirect /> } />
199+ < Route path = "*" element = { RedirectToHomepage } key = "back" />
197200 </ Route >
198201 )
199202}
@@ -204,7 +207,8 @@ window.addEventListener('vite:preloadError', () => {
204207
205208const routes = createRoutesFromElements ( getRoutesList ( ) )
206209
207- // If the URL doesn't have a language prefix, we will use the saved language or default to Hebrew
210+ // The URL carries no language segment; the language is resolved from
211+ // localStorage / the browser locale (see getLang in allTranslations.ts).
208212const router = createBrowserRouter ( routes , {
209213 basename : import . meta. env . VITE_BASE_PATH || '/' ,
210214} )
0 commit comments