Skip to content

Commit 066115c

Browse files
committed
[UXP-123] Code cleaning
1 parent 4953f59 commit 066115c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/app/item-page/cris-item-page-tab.resolver.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ export class CrisItemPageTabResolver implements Resolve<RemoteData<PaginatedList
5151
if (tabsRD.hasSucceeded && tabsRD?.payload?.page?.length > 0) {
5252
// By splitting the url with uuid we can understand if the item is primary item page or a tab
5353
const urlSplit = state.url.split(route.params.id);
54-
const givenTab = urlSplit[1];
54+
const tabArguments = urlSplit[1]?.split('/');
55+
const givenTab = tabArguments[1];
5556
const itemPageRoute = getItemPageRoute(itemRD.payload);
56-
const isValidTab = tabsRD.payload.page.some((tab) => !givenTab || `/${tab.shortname}` === givenTab);
57+
const isValidTab = tabsRD.payload.page.some((tab) => !givenTab || tab.shortname === givenTab);
5758

5859
const mainTab = tabsRD.payload.page.length === 1
5960
? tabsRD.payload.page[0]
@@ -62,7 +63,7 @@ export class CrisItemPageTabResolver implements Resolve<RemoteData<PaginatedList
6263
if (!isValidTab) {
6364
// If wrong tab is given redirect to 404 page
6465
this.router.navigateByUrl(getPageNotFoundRoute(), { skipLocationChange: true, replaceUrl: false });
65-
} else if (givenTab === `/${mainTab.shortname}`) {
66+
} else if (givenTab === mainTab.shortname) {
6667
// If first tab is given redirect to root item page
6768
this.hardRedirectService.redirect(itemPageRoute, 302);
6869
}

0 commit comments

Comments
 (0)