mirror of
https://github.com/documenso/documenso.git
synced 2026-08-23 23:02:22 +10:00
fix: improve unified settings (#3160)
This commit is contained in:
@@ -26,7 +26,7 @@ export const appMiddleware = async (c: Context, next: Next) => {
|
||||
}
|
||||
|
||||
// PRE-HANDLER CODE: Place code here to execute BEFORE the route handler runs.
|
||||
const redirectPath = await handleRedirects(c);
|
||||
const redirectPath = handleRedirects(c);
|
||||
|
||||
if (redirectPath) {
|
||||
debug.log('Redirecting from', path);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { Context } from 'hono';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
export const handleRedirects = async (c: Context): Promise<string | null> => {
|
||||
export const handleRedirects = (c: Context): string | null => {
|
||||
const { req } = c;
|
||||
const path = req.path;
|
||||
|
||||
@@ -15,5 +14,23 @@ export const handleRedirects = async (c: Context): Promise<string | null> => {
|
||||
return '/';
|
||||
}
|
||||
|
||||
// The settings paths below have no index routes, land on their first page instead.
|
||||
// In-app links point directly at the subpages, these only catch direct visits.
|
||||
if (path === '/settings' || path === '/settings/') {
|
||||
return '/settings/profile';
|
||||
}
|
||||
|
||||
const orgSettingsMatch = path.match(/^\/o\/([^/]+)\/settings\/?$/);
|
||||
|
||||
if (orgSettingsMatch) {
|
||||
return `/o/${orgSettingsMatch[1]}/settings/general`;
|
||||
}
|
||||
|
||||
const teamSettingsMatch = path.match(/^\/t\/([^/]+)\/settings\/?$/);
|
||||
|
||||
if (teamSettingsMatch) {
|
||||
return `/t/${teamSettingsMatch[1]}/settings/general`;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user