Skip to content

Commit 7b4b084

Browse files
committed
feat(optimized matcher): Optimization works only when it is insensitive.
1 parent 0cdab2a commit 7b4b084

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Diff for: src/create-matcher.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function optimizedMatcher (
260260
if (isStatic(route)) {
261261
staticMap[normalizedPath] = { index, route }
262262
} else {
263-
const firstLevel = firstLevelStatic(normalizedPath.toLowerCase())
263+
const firstLevel = firstLevelStatic(path.toLowerCase())
264264
if (firstLevel) {
265265
if (!firstLevelStaticMap[firstLevel]) {
266266
firstLevelStaticMap[firstLevel] = []
@@ -273,18 +273,11 @@ function optimizedMatcher (
273273
})
274274

275275
function match (path, params) {
276-
const cleanPath = path.replace(/\/$/, '')
277-
let record = staticMap[cleanPath.toLowerCase()]
278-
279-
if (!record) {
280-
const staticRecordInsensitive = staticMap[cleanPath.toLowerCase()]
281-
if (staticRecordInsensitive && staticRecordInsensitive.route.regex.ignoreCase) {
282-
record = staticRecordInsensitive
283-
}
284-
}
276+
const cleanPath = path.replace(/\/$/, '').toLowerCase()
277+
let record = staticMap[cleanPath]
285278

286279
const firstLevel = firstLevelStatic(path)
287-
const firstLevelRoutes = firstLevelStaticMap[firstLevel && firstLevel.toLowerCase()] || []
280+
const firstLevelRoutes = firstLevelStaticMap[firstLevel] || []
288281

289282
for (let i = 0; i < firstLevelRoutes.length; i++) {
290283
const { index, route } = firstLevelRoutes[i]

0 commit comments

Comments
 (0)