Seite läuft wieder, menü bringt keine fehler mehr
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
import { useLocale } from './useLocale';
|
||||
|
||||
type LocalizedPathInput = string | null | undefined;
|
||||
|
||||
export const useLocalizedRoutes = () => {
|
||||
const locale = useLocale();
|
||||
|
||||
const localizedPath = (path: string) => {
|
||||
const localizedPath = (path: LocalizedPathInput) => {
|
||||
if (typeof path !== 'string' || path.trim().length === 0) {
|
||||
// Diagnose cases where components pass falsy / non-string hrefs (e.g. legacy localized routes, pagination links)
|
||||
// This log allows us to correlate console errors from Inertia with offending components.
|
||||
console.error('[useLocalizedRoutes] Invalid path input detected', {
|
||||
path,
|
||||
locale,
|
||||
stack: new Error().stack,
|
||||
});
|
||||
|
||||
return '/';
|
||||
}
|
||||
|
||||
const trimmed = path.trim();
|
||||
const normalized = trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
||||
|
||||
console.debug('[useLocalizedRoutes] Resolved path', { input: path, normalized, locale });
|
||||
|
||||
// Since prefix-free, return plain path. Locale is handled via session.
|
||||
return path.startsWith('/') ? path : `/${path}`;
|
||||
return normalized;
|
||||
};
|
||||
|
||||
return { localizedPath };
|
||||
|
||||
Reference in New Issue
Block a user