feat(trailing-slash): add alwaysRedirect option to support wildcard routes#4658
Merged
feat(trailing-slash): add alwaysRedirect option to support wildcard routes#4658
alwaysRedirect option to support wildcard routes#4658Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #4658 +/- ##
==========================================
+ Coverage 91.43% 91.45% +0.02%
==========================================
Files 173 173
Lines 11373 11435 +62
Branches 3296 3321 +25
==========================================
+ Hits 10399 10458 +59
- Misses 973 976 +3
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
codler
approved these changes
Feb 2, 2026
codler
reviewed
Feb 11, 2026
| * If `false` (default), it will only redirect when the route is not found (404). | ||
| * @default false | ||
| */ | ||
| strict?: boolean |
There was a problem hiding this comment.
Should we invert the logic? When I hear an option strict it is more limited, hence only applied to 404. So what I mean if we implement as
/**
* If `true` (default), it will only redirect when the route is not found (404).
* If `false`, the middleware will always redirect requests with a trailing slash.
* This is useful for routes with wildcards (`*`).
* @default true
*/
Member
Author
There was a problem hiding this comment.
It is better. How about alwaysRedirect?: boolean?
app.use(trimTrailingSlash({ alwaysRedirect: true }))
Member
Author
There was a problem hiding this comment.
alwaysRedirect is good! I replaced.
strict option to support wildcard routeseager option to support wildcard routes
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
eager option to support wildcard routesalwaysRedirect option to support wildcard routes
Bundle size check
Compiler Diagnostics (tsc)
Compiler Diagnostics (typescript-go)
Reported by octocov |
HTTP Performance Benchmark
|
codler
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #3407
Add
strictalwaysRedirectoption totrimTrailingSlashandappendTrailingSlashmiddleware.When
strict: truealwaysRedirect:true, the middleware redirects before executing handlers, which fixes the issue where trailing slash handling doesn't work with wildcard routes (*).The author should do the following, if applicable
bun run format:fix && bun run lint:fixto format the code