Skip to content

Commit 422a714

Browse files
committed
Check the full URL rather than only the collection id to detect the default path
1 parent 30b4112 commit 422a714

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
131131
}),
132132
);
133133

134+
let comColRoute: string;
135+
if (this.contentType === 'collection') {
136+
comColRoute = getCollectionPageRoute(this.id);
137+
} else if (this.contentType === 'community') {
138+
comColRoute = getCommunityPageRoute(this.id);
139+
}
140+
134141
this.subs.push(combineLatest([
135142
this.allOptions$,
136143
this.router.events.pipe(
@@ -141,15 +148,17 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
141148
),
142149
]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => {
143150
for (const option of navOptions) {
144-
if (url?.split('?')[0].endsWith(`/${this.id}`) && option.id === this.appConfig[this.contentType].defaultBrowseTab) {
151+
if (url?.split('?')[0] === comColRoute && option.id === this.appConfig[this.contentType].defaultBrowseTab) {
145152
void this.router.navigate([option.routerLink], { queryParams: option.params });
153+
break;
146154
} else if (option.routerLink === url?.split('?')[0]) {
147155
this.currentOption$.next(option);
156+
break;
148157
}
149158
}
150159
}));
151160

152-
if (this.router.url?.split('?')[0].endsWith(`/${this.id}`)) {
161+
if (this.router.url?.split('?')[0] === comColRoute) {
153162
this.allOptions$.pipe(
154163
take(1),
155164
).subscribe((allOptions: ComColPageNavOption[]) => {

0 commit comments

Comments
 (0)