diff --git a/lib/common/utils.js b/lib/common/utils.js index 710eccf5199c..5a7861457850 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -254,7 +254,23 @@ function cleanChildrenRoutes(routes, isChild = false) { return routes } -exports.createRoutes = function createRoutes(files, srcDir, pagesDir) { +exports.createRoutes = function createRoutes(files, srcDir) { + + const cloneObject = function(obj) { + var newObj = {}; + + for (var prop in obj) { + if (typeof obj[prop] == 'object') { + newObj[prop] = cloneObject(obj[prop]); + } else { + newObj[prop] = obj[prop]; + } + } + + return newObj; + } + + let routes = [] files.forEach(file => { let keys = file @@ -287,8 +303,12 @@ exports.createRoutes = function createRoutes(files, srcDir, pagesDir) { } } }) + const route2 = cloneObject(route); + route2.path = encodeURI(route2.path); + // Order Routes path - parent.push(route) + parent.push(route); + parent.push(route2); parent.sort((a, b) => { if (!a.path.length) { return -1