-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fixes for strange routing behaviour with optionals. #2683
base: master
Are you sure you want to change the base?
Conversation
Hi @PhilipSkinner, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
@PhilipSkinner, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
Can you rebase please? It will hopefully fix the Travis build error since we've pull in #2685 |
The routing engine incorrectly routes to longer urls in preference of the score, plus it falls back on routing to the last added matching routes instead of the first. I've fixed the sorting comparison method and added some test coverage to show the particular use cases where I found issues.
Sorry for the delay, I've rebased and everything seems to be green now. Looking forward to getting some feedback on the changes I'm proposing. |
You mean if we had
and both matched the request, it would pick This would be a breaking change, but the changes sound reasonable. Thoughts @NancyFx/owners @NancyFx/most-valued-minions ? @PhilipSkinner for the sake of documenting the changes in this PR, can you give an example of the old and new behavior for the 3 (score, length, index) scenarios (update your description, thanks) |
TBH I'm struggling to see how this changed the routing based on the tests. Would it be possible to make the test module return the actual route string instead of a "friendly string"? |
@PhilipSkinner any updates on this? We'll soon be migrating away from project.json to the new csproj format and would like to close off a bunch of pull-requests before that happens. Thanks |
Score taking precedence over length sounds reasonable. |
@PhilipSkinner one last ping mate. The migration to the new csproj format is happening soon and it would probably be easier for you to get this pull-requests in, before that, than having to migrate it yourself. 😄 |
Sorry, I didn't receive any alerts via email about these replies. The system at the moment uses the last, rather than the first. I created a test to prove this before fixing it, the new test cases should ensure that it takes the first one rather than the last. |
Prerequisites
Description
The routing engine incorrectly routes to longer urls in preference of the score, plus it falls back on routing to the last added matching routes instead of the first.
I've fixed the sorting comparison method and added some test coverage to show the particular use cases where I found issues.
The routing engine has been changed to order the matches by:
Why? When I was testing some edge cases I found that the routing engine did "weird" things - it didn't do what I thought it would do. See the new tests to see what I mean.