Skip to content

Support for multiple nested empty subroute paths #908

Closed
@decademoon

Description

@decademoon

Vue version: 2.0.6
Vue-router version: 2.0.2
Reproduction link: http://jsfiddle.net/4wogLvcd/

Given the following routes:

const A = { template: '<div>A <router-view/></div>' };
const B = { template: '<div>B <router-view/></div>' };
const C = { template: '<div>C</div>' };

{
  path: '/a',
  name: 'a',
  component: A,
  children: [
    {
      path: '',
      name: 'b',
      component: B,
      children: [
        {
          path: '',
          name: 'c',
          component: C,
        },
      ],
    },
  ],
}

When matching against the path /a, vue-router will return the b route instead of c. vue-router version 1 correctly returned route c in this case.

Also, vue-router seems to associate route b with path /a/, why the trailing slash? Shouldn't path /a always be resolved to route c (regardless of any trailing slash)?

I managed to get it working the way I want by changing in the addRouteRecord function

pathMap[record.path] = record

to

if (!pathMap[record.path]) pathMap[record.path] = record

that way only the deepest route will be associated with the path, but I don't know if this breaks anything else. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions