🐛 Supprime les slash de fin d'URL
Fixes #1446 Co-authored-by: Maël Thomas <mael.thomas@data.gouv.fr>pull/1538/head
parent
76e8563603
commit
28d7161dd9
|
@ -14,7 +14,7 @@ import { useContext, useMemo } from 'react'
|
|||
import { Helmet } from 'react-helmet'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { Route, Switch } from 'react-router-dom'
|
||||
import { Redirect, Route, Switch } from 'react-router-dom'
|
||||
import {
|
||||
configSituationSelector,
|
||||
situationSelector,
|
||||
|
@ -85,6 +85,15 @@ const Router = () => {
|
|||
<SituationProvider situation={situation}>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Landing} />
|
||||
{/* Removes trailing slashes */}
|
||||
<Route
|
||||
path={'/:url*(/+)'}
|
||||
exact
|
||||
strict
|
||||
render={({ location }) => (
|
||||
<Redirect to={location.pathname.replace(/\/+$/, location.search)} />
|
||||
)}
|
||||
/>
|
||||
<Route path="/iframes" component={Iframes} />
|
||||
<Route component={App} />
|
||||
</Switch>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'Components/ui/index.css'
|
||||
import { useEffect } from 'react'
|
||||
import { hot } from 'react-hot-loader'
|
||||
import { Route, Switch } from 'react-router-dom'
|
||||
import { Redirect, Route, Switch } from 'react-router-dom'
|
||||
import Communauté from '../pages/Communauté'
|
||||
import Documentation from '../pages/Documentation'
|
||||
import Landing from '../pages/Landing'
|
||||
|
@ -34,6 +34,17 @@ const RouterSwitch = () => {
|
|||
>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Landing} />
|
||||
{/* Removes trailing slashes */}
|
||||
<Route
|
||||
path={'/:url*(/+)'}
|
||||
exact
|
||||
strict
|
||||
render={({ location }) => (
|
||||
<Redirect
|
||||
to={location.pathname.replace(/\/+$/, location.search)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Route path="/studio" component={LazyStudio} />
|
||||
<Route path="/documentation" component={Documentation} />
|
||||
<Route exact path="/communauté" component={Communauté} />
|
||||
|
|
Loading…
Reference in New Issue