-
-
Notifications
You must be signed in to change notification settings - Fork 5k
[next] active links: allow trailing slash in route matching (nested routes) #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this should be working as you describe. Currently it doesnt' because with do a simple https://github.com/vuejs/vue-router/blob/next/src/util/route.js#L8 We could maybe solve this with: return (
a.path.replace(/\/$/,'') === b.path.replace(/\/$/,'') &&
a.hash === b.hash &&
isObjectEqual(a.query, b.query)
) @fnlctrl What are your thoughts? |
Does the same problem not apply to |
In what way? hashes don't have this issue with optional trailing slashes. hashes come after the path and don't have any slashes:
|
I thought this check is for when the router uses the hash vs the history api e.g. Then the same issue would occur for |
The hash is removed before route matching: https://github.com/vuejs/vue-router/blob/next/src/history/hash.js#L44 (the So when the code reaches the section discussed previously, any hash present is a "real" hash, not a "fake path" hash. |
Ok, cool! Thanks for the explanation! |
@LinusBorg Though unlikely, I don't quite get what OP wants... What's wrong with adding exact on roter-link? |
|
@LinusBorg Oops, misread that regex...sorry. |
@LinusBorg I agree with removing trailing slashes before comparison. |
@fnlctrl i want my |
@jwahdatehagh Understood. I'll submit a PR shortly. |
@LinusBorg @jwahdatehagh
|
We should add a test for this case as well. |
Yep.. adding one now. |
Nice, thank you so much! |
@jwahdatehagh |
Thanks a log @fnlctrl |
I would like to have nested routes with a default component in the nested-root like so:
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?Vue.js & vue-router.js version
2.0.0-rc.4, 2.0.0-rc.4
Reproduction Link
https://jsfiddle.net/jwahdatehagh/44ed5xxf/1/
The text was updated successfully, but these errors were encountered: