This occurs if normal and hash routes are same (E.g.: https://example.com/path/to/route#/path/to/route
). Therefore, route listener executes twice for this scenario. To fix this you can either use e.hash
flag or switch to hash routing.
route('#/path/to/route', () => { ... });
Silkrouter validates route strings and support routes that are valid for URL. If route string is invalid, you might get "Invalid route" error.
route('/valid/route', ...); // A valid route starts with '/'
route('invalidRoute', ...);
List routes are generic routes.
route([ ... ], () => { ... });
// Is equivalent to
route((e) => {
switch(e.route) { ... }
});
Silkrouter registers a generic route, and hence the only way you can remove a list route is by passing route handler.
unroute([...]); // This will unroute all generic routes
unroute([...], fn); // This will unroute the specific handler
Please note that list routing is experimental.
Edit: As of version 3.4.6 simply passing a list route will not remove generic routes. To remove a list route you need to pass the handler.