route-node
route-node copied to clipboard
Children are not matched when parent's sibling has a shorter path
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
That looks like an edge case because /:x/:y (a) is matched before / (b). I'm not sure I can do anything about it.
Why is a matched? It has no children that has that route?