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

Nested route issue with radix-router #2006

Closed
nsainaney opened this issue Jul 6, 2020 · 1 comment · Fixed by #2177
Closed

Nested route issue with radix-router #2006

nsainaney opened this issue Jul 6, 2020 · 1 comment · Fixed by #2177

Comments

@nsainaney
Copy link
Contributor

nsainaney commented Jul 6, 2020

Steps to reproduce

I believe I found out what causes #670

  1. Create a route e.g. /organizations
  2. Create a nested route e.g /organizations/:orgId/people
  3. Perform a REST call to /organizations, /organizations/xyz, /organizations/xyz/people everything works fine
  4. Perform a Socket call to /organizations/xyz/people - the request goes to /organizations/xyz and not /organizations/xyz/people

In the radix-router, function _findNode(path, rootNode) loops through all the nodes in the router. In the above, the nodes tree looks like so:

+-- organization
|----+-- :__id
|----+-- :orgId
|--------+-- people

When doing a lookup, /organizations/xyz/people, radix matches the __id node (even though it should match :orgId/people

Expected behavior

The router should match the :orgId/people node and not the :__id node

Solutions

Create the following routes instead:

/organizations
/organizations/:__id/people

which creates a proper node tree within radix:
+-- organization
|---+-- :__id
|-------+-- people

The danger here is that :__id is undocumented and may change in the future. Is this ok? The above does not affect the REST transport, just socketio.

@daffl daffl added the Bug label Jul 11, 2020
@daffl
Copy link
Member

daffl commented Jul 11, 2020

Thank you @nsainaney. Definitely looks like a bug. I guess this would be another reason to have our own internal Radix-tree router implementation (the other one would be Deno compatibility).

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

Successfully merging a pull request may close this issue.

2 participants