Skip to content

sort by path params#27

Merged
tophercf merged 1 commit intomainfrom
fix-path-sorting
Mar 24, 2025
Merged

sort by path params#27
tophercf merged 1 commit intomainfrom
fix-path-sorting

Conversation

@tophercf
Copy link
Contributor

Problem
Routes with path parameters were capturing requests meant for more specific routes with literal paths.

Example:
GET /transactions/{transactionId} was capturing requests for
GET /transactions/line-transactions

Solution
Implemented a route prioritization algorithm that sorts paths by specificity:
Routes without path parameters come before routes with parameters
Routes with fewer parameters come before routes with more parameters
Routes with more segments are prioritized over routes with fewer segments
Alphabetical sorting as a tie-breaker

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 24, 2025

@tophercf tophercf requested a review from neilalharris March 24, 2025 19:49
Copy link
Contributor

@NAlexPear NAlexPear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm for it 👍

@tophercf tophercf requested a review from AdamJackman March 24, 2025 21:37
Copy link

@AdamJackman AdamJackman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Also, curious if Robert's suggestion is the simpler solution

@tophercf tophercf merged commit c068ff4 into main Mar 24, 2025
8 checks passed
@tophercf tophercf deleted the fix-path-sorting branch March 24, 2025 21:58
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.

4 participants