Normalize legacy home redirects

This commit is contained in:
2026-06-09 18:45:02 +08:00
parent 39aa708c4f
commit f8bdc3e952
6 changed files with 49 additions and 33 deletions
+33
View File
@@ -0,0 +1,33 @@
import { preferences } from '@vben/preferences';
const LEGACY_HOME_PATTERNS = [
/^\/app\/[^/]+\/(?:form-render|page-render)\//,
/^\/(?:form-render|page-render)\//,
/^\/online-dev(?:\/|$)/,
/^\/online-development(?:\/|$)/,
];
function decodePath(path: string) {
try {
return decodeURIComponent(path);
} catch {
return path;
}
}
function isLegacyHomePath(path: string) {
return LEGACY_HOME_PATTERNS.some((pattern) => pattern.test(path));
}
function normalizeHomePath(path?: null | string) {
if (!path) {
return preferences.app.defaultHomePath;
}
const decodedPath = decodePath(path);
return isLegacyHomePath(decodedPath)
? preferences.app.defaultHomePath
: decodedPath;
}
export { normalizeHomePath };