AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
669 stars 30 forks source link

matches multiple routes #31

Closed sallaben closed 3 years ago

sallaben commented 3 years ago

Hi! This is a nice router. I am using it for my project. I have defined some routes:

<Route path='/dashboard'>
  <Dashboard />
</Route>
<Route path='/:account' let:params>
  <Account {params} />
</Route>

When I visit http://mysite.com/dashboard, I expect /dashboard to match and stop searching for routes. However tinro continues and loads both routes on top of each other, with dashboard as the value of the account parameter in the second route.

Do you know of a clean way to make tinro stop after the first matching route? Thank you. I know that I can use something like /accounts/:account and /dashboard but I am wondering if there is another way.

AlexxNB commented 3 years ago

The idea is that all matched paths are showing. It is simple. So you should avoid the situation like this. We discussed same question here https://github.com/AlexxNB/tinro/issues/7 I'll think about except property or something like this.

sallaben commented 3 years ago

Thank you! The #7 helped me.

If this is how we expect tinro to work, then I think an except property might be too prescriptive. Like you said the user can define their routes more straightforwardly to fix this problem.