Skip to content
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 duplicate child routes with PREFIX_AND_DEFAULT strategy (fixes #292) #294

Merged
merged 2 commits into from
May 9, 2019
Merged

Fix duplicate child routes with PREFIX_AND_DEFAULT strategy (fixes #292) #294

merged 2 commits into from
May 9, 2019

Conversation

rchl
Copy link
Collaborator

@rchl rchl commented May 7, 2019

Fixes two problems when using PREFIX_AND_DEFAULT strategy:

  • parent route with child routes had strange name like
    'undefined__default'. Fixed by not appending default suffix if route
    has children. Such routes don't need name as navigating to them
    wouldn't really work properly anyway (need to navigate to child
    route).

  • Extra child routes were added with 'default' suffix. Fixed by not
    adding extra routes in children arrays. Those don't make sense as
    only parent routes should have extra route with no locale prefix.

Fixes two problems when using PREFIX_AND_DEFAULT strategy:

 - parent route with child routes had strange name like
  'undefined__default'. Fixed by not appending default suffix if route
  has children. Such routes don't need name as navigating to them
  wouldn't really work properly anyway (need to navigate to child
  route).

 - Extra child routes were added with 'default' suffix. Fixed by not
   adding extra routes in children arrays. Those don't make sense as
   only parent routes should have extra route with no locale prefix.
@codecov
Copy link

codecov bot commented May 7, 2019

Codecov Report

Merging #294 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #294   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines           4      4           
=====================================
  Hits            4      4

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b2de84...39c7f5e. Read the comment docs.

@aldarund
Copy link

aldarund commented May 8, 2019

What router.js will be generated for childrens after that pr?

@rchl
Copy link
Collaborator Author

rchl commented May 8, 2019

With #292 testcase, routes will look like this:

    routes: [{
      path: "/about",
      component: _b6e37380,
      name: "about___en-us___default"
    }, {
      path: "/en-us/about",
      component: _b6e37380,
      name: "about___en-us"
    }, {
      path: "/fr/about",
      component: _b6e37380,
      name: "about___fr"
    }, {
      path: "/account",
      component: _2479bbc0,
      children: [{
        path: "child",
        component: _8329b026,
        name: "account-child___en-us___default"
      }]
    }, {
      path: "/en-us/account",
      component: _2479bbc0,
      children: [{
        path: "child",
        component: _8329b026,
        name: "account-child___en-us"
      }]
    }, {
      path: "/fr/account",
      component: _2479bbc0,
      children: [{
        path: "child",
        component: _8329b026,
        name: "account-child___fr"
      }]
    }, {
      path: "/",
      component: _7773bdf6,
      name: "index___en-us___default"
    }, {
      path: "/en-us/",
      component: _7773bdf6,
      name: "index___en-us"
    }, {
      path: "/fr/",
      component: _7773bdf6,
      name: "index___fr"
    }],

Copy link

@aldarund aldarund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@paulgv paulgv merged commit 76d5948 into nuxt-modules:master May 9, 2019
@paulgv
Copy link
Collaborator

paulgv commented May 9, 2019

Thank you @rchl!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants