Skip to content
Prev Previous commit
Next Next commit
fix(router): fixed null reference handling
  • Loading branch information
asvishnyakov committed Sep 9, 2019
commit 2eecce700113cf51d054fa4da1172365205c9846
11 changes: 9 additions & 2 deletions packages/router/src/apply_redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,20 @@ class ApplyRedirects {
ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
return expanded$.pipe(catchError((e: any) => {
if (e instanceof NoMatch) {
return of (new UrlSegmentGroup([], {}));
return of (null);
}
throw e;
}));
}))
.pipe(
map(x => x.find((s: any) => !!s) || new UrlSegmentGroup([], {})),
map(x => {
const match = x.find((s: any) => !!s);
if (match) {
return match;
} else {
throw new EmptyError();
}
}),
catchError((e: any, _: any) => {
if (e instanceof EmptyError || e.name === 'EmptyError') {
if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
Expand Down