mirror of
https://github.com/directus/directus.git
synced 2026-02-10 23:35:25 -05:00
Various changes and fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user