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
fix(utils): flat routes if child routes have absolute paths #7604
Conversation
// if child path is already absolute, do not make any concatenations | ||
if (r.path && r.path.startsWith('/')) { | ||
routes.push(r.path) | ||
} else if (r.path === '' && fileName[fileName.length - 1] === '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think plain old if-else
is more readable than ternary operator with some parentness.
Codecov Report
@@ Coverage Diff @@
## dev #7604 +/- ##
=======================================
Coverage 70.28% 70.28%
=======================================
Files 88 88
Lines 3745 3746 +1
Branches 1019 1018 -1
=======================================
+ Hits 2632 2633 +1
Misses 904 904
Partials 209 209
Continue to review full report at Codecov.
|
I don't think this would be an alternative. I don't think aliasing would be properly recognized by Language is attached to the end of the route name. I don't want to mess with that :) |
@pi0 maybe it would be better to cherry pick the commit to 2.x branch? |
Then it is a nuxt-i18n limitation to support aliases for CEO friendly version. Fix looks good and dev branch is on fix mode so all good! Thanks for contribution ❤️ |
Fixed
flatRoutes
function to work properly if children routes have absolute paths.This was working fine in 2.12, it did break in 2.13.
Types of changes
Description
I am using
nuxt.js
along withnuxt-18n
. I use SEO-friendly, localized routes.For this to work, you have to configure pages to have absolute paths.
Here is a snapshot of my config:
However, it does not work well:
Routes are not properly concatenated. When I look into
router.js
generated file, it looks fine:The reason behind this is, that
flatRoutes
function concatenates parent path and child path, even if child path is absolute.Checklist: