mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-05 20:07:16 +00:00
fix for issue 1234, order less greedy routes first
This commit is contained in:
parent
ae4ecabce0
commit
19d3912290
@ -220,12 +220,15 @@ 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
|
||||||
}
|
}
|
||||||
|
if (i >= _a.length) {
|
||||||
|
res = 1
|
||||||
|
} else {
|
||||||
let y = (_a[i].indexOf('*') > -1) ? 2 : (_a[i].indexOf(':') > -1 ? 1 : 0)
|
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)
|
let z = (_b[i].indexOf('*') > -1) ? 2 : (_b[i].indexOf(':') > -1 ? 1 : 0)
|
||||||
res = y - z
|
res = y - z
|
||||||
@ -233,6 +236,7 @@ export function createRoutes (files, srcDir) {
|
|||||||
res = 1
|
res = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return res === 0 ? -1 : res
|
return res === 0 ? -1 : res
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user