Skip to content

fix(mount): resolve dynamic path prefixes - #5553

Open
usualoma wants to merge 1 commit into
v5from
fix-mount-dynamic-prefix-v5
Open

usualoma wants to merge 1 commit into
v5from
fix-mount-dynamic-prefix-v5

Conversation

@usualoma

Copy link
Copy Markdown
Member

fixes #5546

This PR resolves dynamic prefixes using the request path and the router’s captured parameter values. It also handles intermediate wildcards, including patterns such as /x*/y/*.

Although callers can work around this with replaceRequest, I think this is a case that mount() should handle by default. Since mount() was recently extracted from core into middleware, the additional code seems reasonable.

The implementation accesses the internal match result to obtain parameter values before param() decodes them. Those values are needed to calculate the correct offsets in the request path. This introduces a dependency on internal structures, but I think that is acceptable for middleware shipped with Hono.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • pnpm run check:fix to format and lint the code

@github-actions

Copy link
Copy Markdown

Bundle size check

main (552ea02) #5553 (2020ed0) +/-
Bundle Size (B) 18,335B 18,663B +328B
Bundle Size (KB) 17.91K 18.23K +0.32K

Compiler Diagnostics (tsc)

main (552ea02) #5553 (2020ed0) +/-
Files 83 84 +1
Lines 59,446 59,530 +84
Identifiers 60,625 61,878 +1,253
Symbols 106,532 115,720 +9,188
Types 163,092 171,784 +8,692
Instantiations 414,023 452,803 +38,780
Memory used 208,711K 193,423K -15,288K
I/O read 0.01s 0.01s 0s
I/O write 0s 0s 0s
Parse time 0.29s 0.29s 0s
Bind time 0.1s 0.11s +0.01s
Check time 1.25s 1.33s +0.08s
Emit time 0s 0s 0s
Total time 1.65s 1.74s +0.09s

Compiler Diagnostics (typescript-go)

main (552ea02) #5553 (2020ed0) +/-
Files 215 216 +1
Lines 121,008 121,092 +84
Identifiers 107,353 108,609 +1,256
Symbols 181,164 189,748 +8,584
Types 262,348 271,038 +8,690
Instantiations 621,588 660,480 +38,892
Memory used 153,867K 158,615K +4,748K
Memory allocs 1,781,675 1,852,105 +70,430
Config time 0.001s 0.001s 0s
BuildInfo read time 0.001s 0s -0.001s
Parse time 0.086s 0.106s +0.02s
Bind time 0s 0s 0s
Check time 0.459s 0.519s +0.06s
Emit time 0.004s 0.004s 0s
Changes compute time 0.021s 0.031s +0.01s
Total time 0.601s 0.699s +0.098s

Reported by octocov

@github-actions

Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 85,668.69 105,438.49 83,772.56 67,795.01
hono (current) bun 102,512.58 126,352.85 98,519.65 82,665.23
Change +19.66% +19.84% +17.60% +21.93%

@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v5@b0d28c4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/middleware/mount/index.ts 95.23% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##             v5    #5553   +/-   ##
=====================================
  Coverage      ?   79.96%           
=====================================
  Files         ?      131           
  Lines         ?    10170           
  Branches      ?     2244           
=====================================
  Hits          ?     8132           
  Misses        ?     2038           
  Partials      ?        0           

☔ 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.

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.

1 participant