You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the active link highlights i'd like to scope the children separately. Can we serve the same content on both /home and /home/ and have the /home link active in both cases?
my Regex will only remove trailing slashes, so your example should not be possible.
The problem is that a router-link with a path of /home and the exact attribute will not get the activeClass set if the current route's path is /home/ - even though both routes render the same components and should therefore be considered equal in my opinion.
Activity
LinusBorg commentedon Aug 31, 2016
I think this should be working as you describe. Currently it doesnt' because with do a simple
===
match of the path strings here:https://github.com/vuejs/vue-router/blob/next/src/util/route.js#L8
We could maybe solve this with:
@fnlctrl What are your thoughts?
jwahdatehagh commentedon Aug 31, 2016
Does the same problem not apply to
a.hash === b.hash
? Sorry, i'm not quite acquainted with the internals of the router.LinusBorg commentedon Aug 31, 2016
In what way? hashes don't have this issue with optional trailing slashes. hashes come after the path and don't have any slashes:
http://domain.tld/some/path/#hash?query=params
jwahdatehagh commentedon Aug 31, 2016
I thought this check is for when the router uses the hash vs the history api e.g.
domain.tld#/home/foo
.Then the same issue would occur for
#/home
vs#/home/
.LinusBorg commentedon Aug 31, 2016
The hash is removed before route matching:
https://github.com/vuejs/vue-router/blob/next/src/history/hash.js#L44
(the
getHash()
function does it...)So when the code reaches the section discussed previously, any hash present is a "real" hash, not a "fake path" hash.
jwahdatehagh commentedon Aug 31, 2016
Ok, cool! Thanks for the explanation!
fnlctrl commentedon Sep 1, 2016
@LinusBorg Though unlikely,
a.path.replace(/\/$/,'') === b.path.replace(/\/$/,'')
will be true for '/foo/bar' and '/foobar'.I don't quite get what OP wants... What's wrong with adding exact on roter-link?
LinusBorg commentedon Sep 1, 2016
@fnlctrl
/home
and theexact
attribute will not get theactiveClass
set if the current route's path is/home/
- even though both routes render the same components and should therefore be considered equal in my opinion.fnlctrl commentedon Sep 1, 2016
@LinusBorg Oops, misread that regex...sorry.
Thanks for the explanation! I'll look into it.
fnlctrl commentedon Sep 1, 2016
@LinusBorg I agree with removing trailing slashes before comparison.
12 remaining items