@@ -92,7 +92,7 @@ export function matchPattern(pattern, pathname) {
92
92
93
93
let { regexpSource, paramNames, tokens } = compilePattern ( pattern )
94
94
95
- regexpSource += '/*' // Ignore trailing slashes
95
+ regexpSource += '/*' // Capture path separators
96
96
97
97
// Special-case patterns like '*' for catch-all routes.
98
98
const captureRemaining = tokens [ tokens . length - 1 ] !== '*'
@@ -106,28 +106,27 @@ export function matchPattern(pattern, pathname) {
106
106
107
107
let remainingPathname , paramValues
108
108
if ( match != null ) {
109
- let matchedPath
110
109
if ( captureRemaining ) {
111
110
remainingPathname = match . pop ( )
112
- matchedPath =
111
+ const matchedPath =
113
112
match [ 0 ] . substr ( 0 , match [ 0 ] . length - remainingPathname . length )
114
- } else {
115
- // If this matched at all, then the match was the entire pathname.
116
- matchedPath = match [ 0 ]
117
- remainingPathname = ''
118
- }
119
113
120
- // Ensure we actually match at a path boundary.
121
- if ( remainingPathname && remainingPathname . charAt ( 0 ) !== '/' ) {
122
- // This depends on the leading slash getting added to pathname above to
123
- // work in all cases.
124
- if ( ! matchedPath || matchedPath . charAt ( matchedPath . length - 1 ) !== '/' ) {
114
+ // If we didn't match the entire pathname, then make sure that the match
115
+ // we did get ends at a path separator (potentially the one we added
116
+ // above at the beginning of the path, if the actual match was empty).
117
+ if (
118
+ remainingPathname &&
119
+ matchedPath . charAt ( matchedPath . length - 1 ) !== '/'
120
+ ) {
125
121
return {
126
122
remainingPathname : null ,
127
123
paramNames,
128
124
paramValues : null
129
125
}
130
126
}
127
+ } else {
128
+ // If this matched at all, then the match was the entire pathname.
129
+ remainingPathname = ''
131
130
}
132
131
133
132
paramValues = match . slice ( 1 ) . map (
0 commit comments