router
router copied to clipboard
fix: combining 'end' and 'strict'
This Playground illustrates the problem:
The bottom row is the one that isn't working correctly. This combination of options:
{
path: '/user/',
strict: true,
end: false,
component: ...
}
should match the location path /user/1, but it doesn't.
The reason why is the RegExp is checking for the / twice:
^/user/(?:/|$)
While I've added a lot of extra testing for end: false, only two of those assertions would have failed with the previous code. Specifically, this one on line 666:
matchParams('/home/', '/home/other', {}, options)
and this one on line 673:
matchParams('/home/:p/', '/home/a/b', { p: 'a' }, options)
In both cases they would previously have failed to resolve the route.
Deploy Preview for vue-router canceled.
| Name | Link |
|---|---|
| Latest commit | efc026e56f468ee4137ff5248966cd128c314413 |
| Latest deploy log | https://app.netlify.com/sites/vue-router/deploys/65e99c58b9ed150008af83fe |
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 90.90%. Comparing base (
13303bd) to head (4fce5c0).
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## main #2154 +/- ##
=======================================
Coverage 90.90% 90.90%
=======================================
Files 24 24
Lines 1121 1121
Branches 347 347
=======================================
Hits 1019 1019
Misses 63 63
Partials 39 39
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.