From 69e076ddb0deda9e4120bab095d3369bb19fbd1e Mon Sep 17 00:00:00 2001 From: Kimsible Date: Wed, 28 Apr 2021 22:17:02 +0200 Subject: Refactor client @actorName matcher with new API route --- client/src/app/app-routing.module.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'client/src/app/app-routing.module.ts') diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index c0a2d29e4..23fd52e8b 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -1,11 +1,11 @@ import { NgModule } from '@angular/core' -import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router' +import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } from '@angular/router' import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' import { MenuGuards } from '@app/core/routing/menu-guard.service' import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n' import { PreloadSelectedModulesList } from './core' import { EmptyComponent } from './empty.component' -import { ActorsComponent } from './+actors/actors.component' +import { RootComponent } from './root.component' const routes: Routes = [ { @@ -75,8 +75,20 @@ const routes: Routes = [ redirectTo: 'video-channels' }, { - path: ':actorName', - component: ActorsComponent + matcher: (url): UrlMatchResult => { + // Matches /@:actorName + if (url.length === 1 && url[0].path.match(/^@[\w]+$/gm)) { + return { + consumed: url, + posParams: { + actorName: new UrlSegment(url[0].path.substr(1), {}) + } + } + } + + return null + }, + component: RootComponent }, { path: '', -- cgit v1.2.3