File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,22 @@ const fs = require('fs')
3
3
const qs = require ( 'querystring' )
4
4
5
5
6
- const paramPattern = / ( : | % ) ( [ ^ \/ ] + ) /
6
+ const paramPattern = / (?: : | % ) ( [ ^ \/ ] + ) /
7
7
8
8
// takes routes and decorates them with a 'match' method that will return { params, query } if a path matches
9
9
function addMatch ( route ) {
10
10
let routePath = route . path
11
11
let paramNames = [ ]
12
12
let matched
13
- // find any paths prefixed with a `: `, and treat them as capture groups
13
+ // find any paths prefixed with `:` or `% `, and treat them as capture groups
14
14
while ( ( matched = routePath . match ( paramPattern ) ) !== null ) {
15
15
routePath = routePath . replace ( paramPattern , '([^?/]+)' )
16
16
paramNames . push ( matched [ 1 ] )
17
17
}
18
18
// if a route ends with `index`, allow matching that route without matching the `index` part
19
19
if ( path . basename ( routePath ) === 'index' ) {
20
20
route . isIndex = true
21
- routePath = routePath . replace ( / \/ i n d e x $ / , '/?(: ?index)?' )
21
+ routePath = routePath . replace ( / \/ i n d e x $ / , '/?([:%] ?index)?' )
22
22
}
23
23
// create a regex with our path
24
24
let pattern = new RegExp ( `^${ routePath } (\\?(.*)|$)` , 'i' )
You can’t perform that action at this time.
0 commit comments