route is active even if data is "undef"
AnasSahel opened this issue · comments
Description
The app-route
active
state is true even if the parametrized data is empty.
Imagine those two routes
Route 1 <app-route** pattern="/category"></app-route>
Route 2 <app-route pattern="/category/:id"></app-route>
If the url is http://example.com/category
, then the Route 1 is active
If the url is http://example.com/category/1
or even http://example.com/category/
, then both routes Route 1 and Route 2 are active.
I think that the router should behave like basic ones. I mean, if the data.id
is an empty string, then the route should become inactive (active=false
)
@pi4n0zik Matching on an empty string is required for matching a home page. E.g. mywebsite.com/
with pattern /:page
should then have page === ''
to be able to show a home page.
@TimvdLippe that's correct. However, you can still define a route <app-route pattern="/"></app-route>
which matches the home page and another route <app-route pattern="/:page"></app-route>
to manage the others.
I need this behavior because I built a kind of a router which fires a "route-active" event
with the route/view id
so my my-app element
can activate the right view.
Thanks for your answers :)
related #148