Skip to content

fix(trie-router): match suffix wildcard routes - #5236

Merged
yusukebe merged 6 commits into
mainfrom
fix/trie-router-suffix-wildcard
Aug 17, 2026
Merged

yusukebe merged 6 commits into
mainfrom
fix/trie-router-suffix-wildcard

Conversation

@usualoma

Copy link
Copy Markdown
Member

Fixes #5219

This PR makes TrieRouter recognize a terminal segment ending in * as a suffix wildcard. The prefix is matched literally, so regular expression characters have no special meaning.

There are already two PRs addressing this issue (#5220 and #5230), but they either have a larger implementation footprint or do not cover all relevant cases. This approach is more compact and keeps the fix narrowly scoped to TrieRouter.

It slightly increases the bundle size, but planned follow-up PRs should more than offset that increase.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@codecov

codecov Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.80%. Comparing base (41bdc42) to head (7c7958f).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/router/trie-router/node.ts 87.75% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5236      +/-   ##
==========================================
+ Coverage   79.77%   79.80%   +0.02%     
==========================================
  Files         155      155              
  Lines       10934    10898      -36     
  Branches     2292     2290       -2     
==========================================
- Hits         8723     8697      -26     
+ Misses       2211     2201      -10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ndle-size

refactor(trie-router): trade registration speed for bundle size
…le-size

refactor: Reduce TrieRouter bundle size without a meaningful performance regression
@github-actions

Copy link
Copy Markdown

Bundle size check

main (ef0739d) #5236 (421645a) +/-
Bundle Size (B) 19,013B 18,612B -401B
Bundle Size (KB) 18.57K 18.18K -0.39K

Compiler Diagnostics (tsc)

main (ef0739d) #5236 (421645a) +/-
Files 83 83 0
Lines 59,444 59,444 0
Identifiers 60,621 60,621 0
Symbols 106,532 106,532 0
Types 163,091 163,091 0
Instantiations 414,023 414,023 0
Memory used 170,055K 170,021K -34K
I/O read 0.01s 0.01s 0s
I/O write 0s 0s 0s
Parse time 0.35s 0.36s 0.01s
Bind time 0.14s 0.14s 0s
Check time 1.32s 1.35s 0.03s
Emit time 0s 0s 0s
Total time 1.81s 1.85s 0.04s

Compiler Diagnostics (typescript-go)

main (ef0739d) #5236 (421645a) +/-
Files 215 215 0
Lines 147,092 147,092 0
Identifiers 121,974 121,974 0
Symbols 189,100 189,100 0
Types 262,348 262,348 0
Instantiations 621,588 621,588 0
Memory used 161,806K 161,835K 29K
Memory allocs 1,781,461 1,781,266 -195
Config time 0.001s 0.001s 0s
BuildInfo read time 0s 0s 0s
Parse time 0.116s 0.12s 0.004s
Bind time 0s 0s 0s
Check time 0.441s 0.428s -0.013s
Emit time 0.005s 0.004s -0.001s
Changes compute time 0.043s 0.041s -0.002s
Total time 0.639s 0.667s 0.028s

Reported by octocov

@github-actions

Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 37,094.65 50,708.06 33,423.36 27,152.53
hono (current) bun 36,745.56 49,950.09 32,881.36 27,405.24
Change -0.94% -1.49% -1.62% +0.93%

@usualoma

Copy link
Copy Markdown
Member Author

@yusukebe yusukebe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@yusukebe

Copy link
Copy Markdown
Member
CleanShot 2026-08-17 at 09 37 13@2x

@usualoma Woooow great! Thanks!

@yusukebe
yusukebe merged commit 63bbcf5 into main Aug 17, 2026
20 checks passed
@yusukebe
yusukebe deleted the fix/trie-router-suffix-wildcard branch August 17, 2026 00:37
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.

Suffix wildcard routes (/foo*) return 404 when a sub-app has static + :param routes with the same method

2 participants