test: add coverage for trailing option set to false#428
Merged
blakeembrey merged 1 commit intoMar 30, 2026
Conversation
The `trailing` option (which allows optional trailing delimiter) had no test cases when set to `false`. Added tests covering: - Simple static paths - Paths with trailing slash in the pattern - Parameterized paths - Wildcard paths - Combined trailing: false with end: false - Optional groups with trailing: false
blakeembrey
approved these changes
Mar 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #428 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 1 1
Lines 415 415
Branches 156 157 +1
=======================================
Hits 414 414
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
What
Added test cases for the
trailing: falseoption inmatch(), which previously had no test coverage.Why
While working with
path-to-regexpin an Express API, I noticed thetrailingoption is documented and supported but had zero test cases when set tofalse. Every other match option (end,sensitive,decode,delimiter,encodePath) has dedicated test cases covering its behavior.Tests added
/test): confirms trailing slash is rejected/test/): confirms it requires the trailing slash/:test): verifies params still work correctly/*path): verifies wildcard captures with trailing delimiter behaviortrailing: false+end: false: verifies both options interact correctly{/:test}/bar): verifies trailing slash rejection with optional segmentsAll existing tests continue to pass.