route-node icon indicating copy to clipboard operation
route-node copied to clipboard

Children are not matched when parent's sibling has a shorter path

Open whs opened this issue 7 years ago • 2 comments

Sorry for the title, I don't know how to describe this problem clearly.

This is probably related to #17. The case can be demonstrated by this test:

it('should able to match longer subpath that has similar path on the root', ( ) => {

    const node = new RouteNode('', '', [
        new RouteNode('a', '/:x/:y'),
        new RouteNode('b', '/', [
            new RouteNode('c', 'a/b/c'),
        ]),
    ]);

    withoutMeta(node.matchPath('/a/b/c')).should.eql({ name: 'c', params: { } });

});

matchPath will return {} even though there is a route for /a/b/c

whs avatar Feb 22 '18 04:02 whs

That looks like an edge case because /:x/:y (a) is matched before / (b). I'm not sure I can do anything about it.

troch avatar Feb 22 '18 11:02 troch

Why is a matched? It has no children that has that route?

shavyg2 avatar Jul 24 '19 12:07 shavyg2