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: routes not being considered in the correct order #5

Merged
merged 1 commit into from
May 3, 2023

Conversation

justin-caldicott
Copy link
Contributor

@justin-caldicott justin-caldicott commented May 3, 2023

Expected

If you have the following routes defined:
/user/[id]
/user/[id]/locations

Then a request to /user/[id]/locations will resolve to that, more specific, route.

Actual

A request to /user/[id]/locations resolves to /user/[id] as it comes across this one first.

Proposed change

This PR sorts the dynamic routes to have the longest routes first, which will ensure that, where routes are nested as such, the most specific route will be chosen.

Testing

Ideally I'd have extended tests to cover this case, but there aren't any and it feels outside of the scope of this change to add them. I've created an issue for this.

@mtbrault mtbrault merged commit 6d0bf6b into mtbrault:main May 3, 2023
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.

2 participants