Fix router (#39)

* on click, do not add route if included in pathname

* corrected readme tools table links

* remove code blocks inside links

* corrected hypercore and hyperwarm links

---------

Co-authored-by: rafapaezbas <rafa@holepunch.com>
This commit is contained in:
rafapaezbas
2024-02-14 14:11:39 +01:00
committed by GitHub
parent 2095b95c23
commit 636b931276
4 changed files with 12 additions and 8 deletions

View File

@@ -30,7 +30,11 @@ customElements.define('app-router', class AppRouter extends HTMLElement {
if (evt.target.origin !== location.origin) return window.open(evt.target.href)
const { tagName } = evt.target.getRootNode().host || {}
const route = tagName ? this.getAttribute(tagName) : ''
this.load(route + evt.target.pathname).catch(console.error)
if (evt.target.pathname.startsWith(route)) {
this.load(evt.target.pathname).catch(console.error)
} else {
this.load(route + evt.target.pathname).catch(console.error)
}
}
connectedCallback () {