fix(front-end): fix security #39

Merged
JoeKung merged 2 commits from dev into main 2026-03-11 11:42:50 +01:00

View File

@@ -1,4 +1,13 @@
import { Routes } from '@angular/router'; import { CanMatchFn, Routes } from '@angular/router';
const SUPPORTED_LANGS = new Set(['it', 'en', 'de', 'fr']);
const langPrefixCanMatch: CanMatchFn = (_route, segments) => {
if (segments.length === 0) {
return false;
}
return SUPPORTED_LANGS.has(segments[0].path.toLowerCase());
};
const appChildRoutes: Routes = [ const appChildRoutes: Routes = [
{ {
@@ -116,6 +125,7 @@ const appChildRoutes: Routes = [
export const routes: Routes = [ export const routes: Routes = [
{ {
path: ':lang', path: ':lang',
canMatch: [langPrefixCanMatch],
loadComponent: () => loadComponent: () =>
import('./core/layout/layout.component').then((m) => m.LayoutComponent), import('./core/layout/layout.component').then((m) => m.LayoutComponent),
children: appChildRoutes, children: appChildRoutes,