mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-04 19:37:18 +00:00
fix for issue 1234, order less greedy routes first
This commit is contained in:
parent
ae4ecabce0
commit
19d3912290
@ -220,17 +220,21 @@ export function createRoutes (files, srcDir) {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
let res = 0
|
let res = 0
|
||||||
let _a = a.path.split('/')
|
const _a = a.path.split('/')
|
||||||
let _b = b.path.split('/')
|
const _b = b.path.split('/')
|
||||||
for (let i = 0; i < _a.length; i++) {
|
for (let i = 0; i < _a.length >= _b.length ? _a.length : _b.length; i++) {
|
||||||
if (res !== 0) {
|
if (res !== 0) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
let y = (_a[i].indexOf('*') > -1) ? 2 : (_a[i].indexOf(':') > -1 ? 1 : 0)
|
if (i >= _a.length) {
|
||||||
let z = (_b[i].indexOf('*') > -1) ? 2 : (_b[i].indexOf(':') > -1 ? 1 : 0)
|
|
||||||
res = y - z
|
|
||||||
if (i === _b.length - 1 && res === 0) {
|
|
||||||
res = 1
|
res = 1
|
||||||
|
} else {
|
||||||
|
let y = (_a[i].indexOf('*') > -1) ? 2 : (_a[i].indexOf(':') > -1 ? 1 : 0)
|
||||||
|
let z = (_b[i].indexOf('*') > -1) ? 2 : (_b[i].indexOf(':') > -1 ? 1 : 0)
|
||||||
|
res = y - z
|
||||||
|
if (i === _b.length - 1 && res === 0) {
|
||||||
|
res = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res === 0 ? -1 : res
|
return res === 0 ? -1 : res
|
||||||
|
Loading…
Reference in New Issue
Block a user