Skip to content

Commit db256c4

Browse files
[DSC-2269] move logic into resolver
1 parent 6d003df commit db256c4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ export const itemPageResolver: ResolveFn<RemoteData<Item>> = (
7575
map((rd: RemoteData<Item>) => {
7676
store.dispatch(new ResolvedAction(state.url, rd.payload));
7777
if (rd.hasSucceeded && hasValue(rd.payload)) {
78+
const itemRoute = router.parseUrl(getItemPageRoute(rd.payload)).toString();
7879
// Check if custom url not empty and if the current id parameter is different from the custom url redirect to custom url
7980
if (hasValue(rd.payload.metadata) && isNotEmpty(rd.payload.metadata['cris.customurl'])) {
8081
if (route.params.id !== rd.payload.metadata['cris.customurl'][0].value) {
81-
const newUrl = state.url.replace(route.params.id, rd.payload.metadata['cris.customurl'][0].value);
82+
const newUrl = itemRoute.replace(route.params.id, rd.payload.metadata['cris.customurl'][0].value);
8283
router.navigateByUrl(newUrl);
8384
}
8485
} else {
@@ -88,7 +89,6 @@ export const itemPageResolver: ResolveFn<RemoteData<Item>> = (
8889
// or semicolons) and thisRoute has been encoded with that function. If we want to compare
8990
// it with itemRoute, we have to run itemRoute through Angular's version as well to ensure
9091
// the same characters are encoded the same way.
91-
const itemRoute = router.parseUrl(getItemPageRoute(rd.payload)).toString();
9292

9393
if (!thisRoute.startsWith(itemRoute)) {
9494
const itemId = rd.payload.uuid;

0 commit comments

Comments
 (0)