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 Jun 18, 2021
1 parent 737cd4f commit 5b06aa1
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 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);
router.setRoutes(
[
// Redirect to URL without trailing slash
{
path: '(.*)/',
action: (context, commands) => {
const newPath = context.pathname.slice(0, -1);
return commands.redirect(newPath);
},
},
},
...routes,
]);
...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 5b06aa1

Please sign in to comment.