Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7b4b084

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

File tree

Expand file treeCollapse file tree

1 file changed

+4
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-11
lines changed
Open diff view settings
Collapse file

‎src/create-matcher.js‎

Copy file name to clipboardExpand all lines: src/create-matcher.js
+4-11Lines changed: 4 additions & 11 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.