mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-18 12:52:52 +00:00
redirects to / implemented when path not matching or is invalid
This commit is contained in:
parent
114e8c3fdf
commit
ffec89d3cc
1 changed files with 11 additions and 0 deletions
|
|
@ -31,10 +31,17 @@ class Router extends Component {
|
|||
const hashIndex = window.location.href.indexOf('#');
|
||||
const hashPath = hashIndex === -1 ? '' : window.location.href.substring(hashIndex + 1);
|
||||
const path = joinPaths('/', hashPath);
|
||||
if (hashPath !== path) {
|
||||
window.location.replace(`#${path}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let pathMatched = false;
|
||||
for (let viewConfigIndex = 0; viewConfigIndex < this.props.config.views.length; viewConfigIndex++) {
|
||||
const viewConfig = this.props.config.views[viewConfigIndex];
|
||||
for (const routeConfig of viewConfig.routes) {
|
||||
if (matchPath(path, routeConfig)) {
|
||||
pathMatched = true;
|
||||
this.setState(({ views }) => ({
|
||||
views: views.map((view, viewIndex) => {
|
||||
if (viewIndex > viewConfigIndex) {
|
||||
|
|
@ -56,6 +63,10 @@ class Router extends Component {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pathMatched) {
|
||||
window.location.replace('#/');
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue