Fixed an issue where in hash mode if a route started with / it would break the navigation.
This commit is contained in:
		| @@ -252,6 +252,11 @@ class Router { | ||||
|     static navigate(route, data = null, refresh = false) { | ||||
|         if (refresh) { | ||||
|             if (Router.hashMode) { | ||||
|                 //In hash mode the route can't start with /, we have to handle it here. | ||||
|                 if (route.startsWith("/")) { | ||||
|                     route = route.substr(1); | ||||
|                 } | ||||
|  | ||||
|                 window.location.hash = route; | ||||
|                 window.location.reload(); | ||||
|             } else { | ||||
| @@ -259,13 +264,19 @@ class Router { | ||||
|             } | ||||
|         } else { | ||||
|             if (Router.hashMode) { | ||||
|                 //In hash mode the route can't start with /, we have to handle it here. | ||||
|                 if (route.startsWith("/")) { | ||||
|                     route = route.substr(1); | ||||
|                 } | ||||
|  | ||||
|                 window.location.hash = route; | ||||
|                 Router.states.push(route); | ||||
|             } else { | ||||
|                 window.history.pushState(route, route, route); | ||||
|                 Router.states.push(route); | ||||
|             } | ||||
|  | ||||
|             //Push the route to our internal states | ||||
|             Router.states.push(route); | ||||
|  | ||||
|             //Create a new pushstate event and fire it. | ||||
|             var event = new Event("pushstate"); | ||||
|             event.data = data; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user