diff options
author | Kimsible <kimsible@users.noreply.github.com> | 2021-04-28 22:17:02 +0200 |
---|---|---|
committer | Kimsible <kimsible@users.noreply.github.com> | 2021-05-05 11:47:03 +0200 |
commit | 69e076ddb0deda9e4120bab095d3369bb19fbd1e (patch) | |
tree | 6576a6293b9e76ce385813f62376e15a7e05001f /client/src/app/app-routing.module.ts | |
parent | 08ac081b37cd6115634e8951608116fe0f13032b (diff) | |
download | PeerTube-69e076ddb0deda9e4120bab095d3369bb19fbd1e.tar.gz PeerTube-69e076ddb0deda9e4120bab095d3369bb19fbd1e.tar.zst PeerTube-69e076ddb0deda9e4120bab095d3369bb19fbd1e.zip |
Refactor client @actorName matcher with new API route
Diffstat (limited to 'client/src/app/app-routing.module.ts')
-rw-r--r-- | client/src/app/app-routing.module.ts | 20 |
1 files changed, 16 insertions, 4 deletions
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 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router' | 2 | import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } from '@angular/router' |
3 | import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' | 3 | import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' |
4 | import { MenuGuards } from '@app/core/routing/menu-guard.service' | 4 | import { MenuGuards } from '@app/core/routing/menu-guard.service' |
5 | import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n' | 5 | import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n' |
6 | import { PreloadSelectedModulesList } from './core' | 6 | import { PreloadSelectedModulesList } from './core' |
7 | import { EmptyComponent } from './empty.component' | 7 | import { EmptyComponent } from './empty.component' |
8 | import { ActorsComponent } from './+actors/actors.component' | 8 | import { RootComponent } from './root.component' |
9 | 9 | ||
10 | const routes: Routes = [ | 10 | const routes: Routes = [ |
11 | { | 11 | { |
@@ -75,8 +75,20 @@ const routes: Routes = [ | |||
75 | redirectTo: 'video-channels' | 75 | redirectTo: 'video-channels' |
76 | }, | 76 | }, |
77 | { | 77 | { |
78 | path: ':actorName', | 78 | matcher: (url): UrlMatchResult => { |
79 | component: ActorsComponent | 79 | // Matches /@:actorName |
80 | if (url.length === 1 && url[0].path.match(/^@[\w]+$/gm)) { | ||
81 | return { | ||
82 | consumed: url, | ||
83 | posParams: { | ||
84 | actorName: new UrlSegment(url[0].path.substr(1), {}) | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | return null | ||
90 | }, | ||
91 | component: RootComponent | ||
80 | }, | 92 | }, |
81 | { | 93 | { |
82 | path: '', | 94 | path: '', |