Releases: obsidian/oak
v5.0.0 - Route Matching Priority Fix
Critical Bug Fix
This release fixes a critical route matching priority bug where static routes were incorrectly matched by parameterized routes.
What Was Fixed
Problem: When both static and parameterized routes existed at the same path level, the parameterized route would incorrectly capture static segments. For example:
tree.add "/users/new", "new_action"
tree.add "/users/:user_id", "show_action"
result = tree.find("/users/new")
# Before: Matched /users/:user_id with user_id="new" ❌
# After: Matches /users/new correctly ✅Root Cause: The searcher was iterating through all matching child nodes and overwriting results in find_first mode, even after finding a valid match.
Solution: The search now stops at the first match when in single-result mode (Tree#find), ensuring static routes (which are already sorted first) are prioritized over dynamic routes (:param) and glob routes (*param).
Breaking Changes
None. This fix restores the correct behavior from v4.0.1.
Compatibility
- Crystal >= 0.23.1
- All existing tests pass (64/64)
- No API changes
Migration
No migration needed. Simply update your shard.yml:
```yaml
dependencies:
oak:
github: obsidian/oak
version: ~> 5.0
```
What's Changed
- Fixed route matching priority in searcher (src/oak/searcher.cr:53)
- Bumped version to 5.0.0
Full Changelog: v4.0.1...v5.0.0