fix: improve unified settings (#3160)

This commit is contained in:
David Nguyen
2026-08-10 14:57:19 +10:00
committed by GitHub
parent fc95ee9ead
commit 797f5c0e79
24 changed files with 129 additions and 114 deletions
+1 -1
View File
@@ -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);
+19 -2
View File
@@ -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;
};