-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(utils): error when router.trailingSlash is false #6515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #6515 +/- ##
=======================================
Coverage 95.67% 95.67%
=======================================
Files 79 79
Lines 2706 2706
Branches 698 698
=======================================
Hits 2589 2589
Misses 101 101
Partials 16 16
Continue to review full report at Codecov.
|
packages/utils/src/route.js
Outdated
@@ -177,6 +177,9 @@ export const createRoutes = function createRoutes ({ | |||
if (trailingSlash !== undefined) { | |||
route.pathToRegexpOptions = { ...route.pathToRegexpOptions, strict: true } | |||
route.path = route.path.replace(/\/+$/, '') + (trailingSlash ? '/' : '') | |||
if (route.path === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about?
route.path = route.path.replace(/\/+$/, '') + (trailingSlash ? '/' : '') || '/'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good.
I'll adopt this way, thx!
LGTM! We should definitely make sure that users don't trip here like I did 🙈 - #6339 |
Types of changes
Description
Fix #6501
Checklist: