From 8661c57e88862bdf3ad548c9b5a471d15c8884e3 Mon Sep 17 00:00:00 2001 From: Alexandre Chopin Date: Thu, 9 Feb 2017 01:18:29 +0100 Subject: [PATCH] fix routes bug order --- lib/build.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/build.js b/lib/build.js index abae52c55e..36b71f8aa7 100644 --- a/lib/build.js +++ b/lib/build.js @@ -256,6 +256,8 @@ function createRoutes (files, srcDir) { // Order Routes path parent.push(route) parent.sort((a, b) => { + if (!a.path.length || a.path === '/') { return -1 } + if (!b.path.length || b.path === '/') { return 1 } var res = 0 var _a = a.path.split('/') var _b = b.path.split('/') @@ -268,10 +270,10 @@ function createRoutes (files, srcDir) { res = y - z } } else { - res = (res === 0) ? 1 : res + res = (res === 0) ? -1 : res } }) - return res === 0 ? ((_a.length === _b.length) ? _a[_max].length - _b[_max].length : -1) : res + return res === 0 ? ((_a.length === _b.length) ? _a[_max].length - _b[_max].length : _b.length - _a.length) : res }) }) return cleanChildrenRoutes(routes)