Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history.pushState to a unexsting path doesn't redirect correctly #11

Open
pedrokohler opened this issue Sep 8, 2020 · 0 comments
Open

Comments

@pedrokohler
Copy link

pedrokohler commented Sep 8, 2020

window.history.pushState(null, '', redirectTo || 'menu');

I'm using the code above to decide where my Login page will redirect to when it is accessed while the user is already logged in.

The problem is that, even though my routes are as follows:

customElements.whenDefined('router-slot').then(async () => {
  const routerSlot = document.querySelector('router-slot');
  await routerSlot.add([
    {
      path: 'menu',
      component: () => import('./pages/menu-page'),
      guards: [sessionGuard],
    },
    {
      path: 'send-song',
      component: () => import('./pages/send-song-page'),
      guards: [sessionGuard],
    },
    {
      path: 'vote',
      component: () => import('./pages/vote-page'),
      guards: [sessionGuard],
    },
    {
      path: 'logout',
      component: () => import('./pages/logout-page'),
      guards: [sessionGuard],
    },
    {
      path: '',
      component: () => import('./pages/login-page'),
    },
    {
      path: '**',
      redirectTo: 'menu',
    },
  ]);
});

Meaning that I have a path: '**' with a redirectTo: 'menu', it doesn't work properly if the pushState's redirectTo is nonsense. In this case it just tries to access the nonsensical route instead of redirecting to 'menu'.

Is this a bug or am I doing something wrong?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant