Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Skip router render meanwhile there is no outlet
Browse files Browse the repository at this point in the history
  • Loading branch information
abdonrd committed May 5, 2021
1 parent d7c0819 commit f15d2b8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ import { routes } from './routes.js';

const router = new Router();

router.setRoutes([
// Redirect to URL without trailing slash
{
path: '(.*)/',
action: (context, commands) => {
const newPath = context.pathname.slice(0, -1);
return commands.redirect(newPath);
}
},
...routes
]);
router.setRoutes(
[
// Redirect to URL without trailing slash
{
path: '(.*)/',
action: (context, commands) => {
const newPath = context.pathname.slice(0, -1);
return commands.redirect(newPath);
}
},
...routes
],
true
);

export const attachRouter = (outlet: HTMLElement) => {
router.setOutlet(outlet);
router.render(window.location, true);
};

export const urlForName = (name: string, params?: Params) => {
Expand Down

0 comments on commit f15d2b8

Please sign in to comment.