diff --git a/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts b/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts index feefb468cb..5b8f12a75d 100644 --- a/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts +++ b/src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts @@ -131,6 +131,13 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit { }), ); + let comColRoute: string; + if (this.contentType === 'collection') { + comColRoute = getCollectionPageRoute(this.id); + } else if (this.contentType === 'community') { + comColRoute = getCommunityPageRoute(this.id); + } + this.subs.push(combineLatest([ this.allOptions$, this.router.events.pipe( @@ -141,15 +148,17 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit { ), ]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => { for (const option of navOptions) { - if (url?.split('?')[0].endsWith(`/${this.id}`) && option.id === this.appConfig[this.contentType].defaultBrowseTab) { + if (url?.split('?')[0] === comColRoute && option.id === this.appConfig[this.contentType].defaultBrowseTab) { void this.router.navigate([option.routerLink], { queryParams: option.params }); + break; } else if (option.routerLink === url?.split('?')[0]) { this.currentOption$.next(option); + break; } } })); - if (this.router.url?.split('?')[0].endsWith(`/${this.id}`)) { + if (this.router.url?.split('?')[0] === comColRoute) { this.allOptions$.pipe( take(1), ).subscribe((allOptions: ComColPageNavOption[]) => {