Skip to content

Commit b3d53db

Browse files
authored
Fixes from @jesseditson
1 parent dcfb5d0 commit b3d53db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ const fs = require('fs')
33
const qs = require('querystring')
44

55

6-
const paramPattern = /(:|%)([^\/]+)/
6+
const paramPattern = /(?::|%)([^\/]+)/
77

88
// takes routes and decorates them with a 'match' method that will return { params, query } if a path matches
99
function addMatch (route) {
1010
let routePath = route.path
1111
let paramNames = []
1212
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
1414
while ((matched = routePath.match(paramPattern)) !== null) {
1515
routePath = routePath.replace(paramPattern, '([^?/]+)')
1616
paramNames.push(matched[1])
1717
}
1818
// if a route ends with `index`, allow matching that route without matching the `index` part
1919
if (path.basename(routePath) === 'index') {
2020
route.isIndex = true
21-
routePath = routePath.replace(/\/index$/, '/?(:?index)?')
21+
routePath = routePath.replace(/\/index$/, '/?([:%]?index)?')
2222
}
2323
// create a regex with our path
2424
let pattern = new RegExp(`^${routePath}(\\?(.*)|$)`, 'i')

0 commit comments

Comments
 (0)