Skip to content

Commit f533dfa

Browse files
committed
fix: flow
1 parent 60ff22c commit f533dfa

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/create-matcher.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function createMatcher (
5454
redirectedFrom?: Location
5555
): Route {
5656
const location = normalizeLocation(raw, currentRoute, false, router)
57-
const { name } = location
57+
const { name, path } = location
5858

5959
if (name) {
6060
const record = nameMap[name]
@@ -80,18 +80,17 @@ export function createMatcher (
8080

8181
location.path = fillParams(record.path, location.params, `named route "${name}"`)
8282
return _createRoute(record, location, redirectedFrom)
83-
} else if (location.path) {
83+
} else if (path) {
8484
location.params = {}
85-
const staticRecord = pathMap[location.path]
85+
const staticRecord = pathMap[path]
8686
if (staticRecord) {
87-
if (matchRoute(staticRecord.regex, location.path, location.params)) {
87+
if (matchRoute(staticRecord.regex, path, location.params)) {
8888
return _createRoute(staticRecord, location, redirectedFrom)
8989
}
9090
}
9191
for (let i = 0; i < pathList.length; i++) {
92-
const path = pathList[i]
93-
const record = pathMap[path]
94-
if (matchRoute(record.regex, location.path, location.params)) {
92+
const record = pathMap[pathList[i]]
93+
if (matchRoute(record.regex, path, location.params)) {
9594
return _createRoute(record, location, redirectedFrom)
9695
}
9796
}

src/create-route-map.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ function addRouteRecord (
144144
})
145145
}
146146

147-
if (
148-
!pathMap[record.path] &&
149-
!Object.values(pathMap).some(r => r.path.indexOf('*') === -1 && record.path.match(r.regex))
150-
) {
147+
if (!pathMap[record.path] && !pathList.some(pathItem => {
148+
const r = pathMap[pathItem]
149+
return r.path.indexOf('*') === -1 && record.path.match(r.regex)
150+
})) {
151151
pathList.push(record.path)
152152
pathMap[record.path] = record
153153
}

0 commit comments

Comments
 (0)