vaadin / router

Small and powerful client-side router for Web Components. Framework-agnostic.
https://vaadin.com/router
Apache License 2.0
415 stars 51 forks source link

Router.go should find a route based on its defined path relative to the base href #802

Open nweldev opened 2 years ago

nweldev commented 2 years ago

Description of the bug

When using a <base href> element, router.baseURL correctly retrieves the right value. However, when trying to call Router.go(relativePath), no route is found. Calling Router.go(document.querySelector('base')?.href + relativePath) does work as a workaround.

Minimal reproducible example

See https://github.com/blindnet-io/privacy-components-web/pull/84

Expected behaviour

When defining the following route:

{ path: '/myroute', component: 'app-my-component' }

And a base href:

<base href="/my/subdir/`>

Calling Router.go('/myroute') should find and load the associated route.

Actual behavior

Only Router.go('/my/subdir/myroute') works (adding the base href manually).

Versions: