Various changes and fixes

This commit is contained in:
rijkvanzanten
2020-07-03 12:48:45 -04:00
parent e506b2dd95
commit be20289ae5
13 changed files with 249 additions and 147 deletions

View File

@@ -14,11 +14,11 @@ export function defineModule(config: ModuleDefineParam | ((context: ModuleContex
if (options.routes !== undefined) {
options.routes = options.routes.map((route) => {
if (route.path) {
route.path = `/:project/${options.id}${route.path}`;
route.path = `/${options.id}${route.path}`;
}
if (route.redirect) {
route.redirect = `/:project/${options.id}${route.redirect}`;
route.redirect = `/${options.id}${route.redirect}`;
}
return route;

View File

@@ -10,7 +10,7 @@ const moduleRoutes = modules
replaceRoutes((routes) => insertBeforeProjectWildcard(routes, moduleRoutes));
export function insertBeforeProjectWildcard(currentRoutes: RouteConfig[], routesToBeAdded: RouteConfig[]) {
// Find the index of the /:project/* route, so we can insert the module routes right above that
const wildcardIndex = currentRoutes.findIndex((route) => route.path === '/:project/*');
// Find the index of the /* route, so we can insert the module routes right above that
const wildcardIndex = currentRoutes.findIndex((route) => route.path === '/*');
return [...currentRoutes.slice(0, wildcardIndex), ...routesToBeAdded, ...currentRoutes.slice(wildcardIndex)];
}