This commit is contained in:
Vincent van der Wal
2026-08-01 15:07:28 +02:00
parent 9806396476
commit 774afa6c65
45 changed files with 1515 additions and 239 deletions
+7 -3
View File
@@ -1,5 +1,7 @@
import { error, redirect } from '@sveltejs/kit';
import { deLocalizeHref, localizeHref } from '$lib/paraglide/runtime';
import type { GeoLocation } from '$lib/stores/settings';
export const geoLocationNameToRoute = (name: string) => {
@@ -117,10 +119,12 @@ export async function resolveLocationFromRoute({
// trailingSlash is 'always' (see routes/+layout.ts), so the router serves
// every path with a trailing slash. Match that here or the equality check
// never holds and the redirect loops forever.
// never holds and the redirect loops forever. The comparison also has to
// ignore the locale prefix the URL carries, while the redirect keeps it -
// otherwise every localized URL would bounce back to English.
const canonicalPath = `${routePrefix}${buildLocationRoute(location)}/`;
if (event.url.pathname !== canonicalPath) {
throw redirect(303, canonicalPath);
if (deLocalizeHref(event.url.pathname) !== canonicalPath) {
throw redirect(303, localizeHref(canonicalPath));
}
return location;