Normalize legacy home redirects
This commit is contained in:
@@ -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 };
|
||||
Reference in New Issue
Block a user