@@ -23,6 +23,7 @@ import { Route, Switch, withRouter } from 'react-router-dom';
23
23
import { Link } from 'react-router-dom' ;
24
24
import SideMenu from './side_menu.jsx' ;
25
25
import WelcomePage from './welcome_page.jsx' ;
26
+ import VERSIONS from './versions.json' ;
26
27
import './css/app.css' ;
27
28
import './css/reset.css' ;
28
29
import './css/highlight.css' ;
@@ -53,8 +54,13 @@ class App extends Component {
53
54
constructor ( props ) {
54
55
super ( props ) ;
55
56
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
+ }
58
64
this . state = {
59
65
slideoutIsOpen : true ,
60
66
version : version ,
@@ -239,7 +245,7 @@ class App extends Component {
239
245
path = "/:version/docs/api/@stdlib/:pkg*"
240
246
render = { this . renderReadme }
241
247
/>
242
- < Route exact path = "/:version/docs/api " >
248
+ < Route exact path = "/:version? " >
243
249
< WelcomePage version = { this . state . version } />
244
250
</ Route >
245
251
</ Switch >
0 commit comments