fix for issue 1234, order less greedy routes first

This commit is contained in:
pimlie 2017-08-03 17:20:38 +02:00
parent ae4ecabce0
commit 19d3912290

View File

@ -220,12 +220,15 @@ export function createRoutes (files, srcDir) {
return 1
}
let res = 0
let _a = a.path.split('/')
let _b = b.path.split('/')
for (let i = 0; i < _a.length; i++) {
const _a = a.path.split('/')
const _b = b.path.split('/')
for (let i = 0; i < _a.length >= _b.length ? _a.length : _b.length; i++) {
if (res !== 0) {
break
}
if (i >= _a.length) {
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
@ -233,6 +236,7 @@ export function createRoutes (files, srcDir) {
res = 1
}
}
}
return res === 0 ? -1 : res
})
})