@@ -23,6 +23,7 @@ import { Route, Switch, withRouter } from 'react-router-dom';
2323import { Link } from 'react-router-dom' ;
2424import SideMenu from './side_menu.jsx' ;
2525import WelcomePage from './welcome_page.jsx' ;
26+ import VERSIONS from './versions.json' ;
2627import './css/app.css' ;
2728import './css/reset.css' ;
2829import './css/highlight.css' ;
@@ -53,8 +54,13 @@ class App extends Component {
5354 constructor ( props ) {
5455 super ( props ) ;
5556
56- const pathname = props . history . location . pathname ;
57- const version = pathname . substring ( 1 , pathname . indexOf ( '/docs' ) ) ;
57+ let pathname = props . history . location . pathname ;
58+ let version = pathname . substring ( 1 , pathname . indexOf ( '/docs' ) ) ;
59+ if ( ! VERSIONS . includes ( version ) ) {
60+ pathname = pathname . replace ( version , VERSIONS [ 0 ] ) ;
61+ this . props . history . push ( pathname ) ;
62+ version = VERSIONS [ 0 ] ;
63+ }
5864 this . state = {
5965 slideoutIsOpen : true ,
6066 version : version ,
@@ -239,7 +245,7 @@ class App extends Component {
239245 path = "/:version/docs/api/@stdlib/:pkg*"
240246 render = { this . renderReadme }
241247 />
242- < Route exact path = "/:version/docs/api " >
248+ < Route exact path = "/:version? " >
243249 < WelcomePage version = { this . state . version } />
244250 </ Route >
245251 </ Switch >
0 commit comments