Fix browser back navigation when viewing a bitstream#5978
Open
jesielviana wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts bitstream download routing so the Angular :id/download route can activate (and therefore be added to browser history) before performing the redirect to the bitstream content URL, addressing incorrect browser-back behavior when viewing a bitstream.
Changes:
- Removed the pre-activation
canActivateredirect guard from the Angular bitstream download route (:id/download). - Added a focused route-configuration spec to ensure the Angular download route has no pre-activation redirect guard while legacy bitstream URL routes retain their redirect guards.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/app/bitstream-page/bitstream-page-routes.ts |
Removes the pre-activation redirect guard from the Angular download route while keeping legacy routes guarded. |
src/app/bitstream-page/bitstream-page-routes.spec.ts |
Adds unit tests asserting the new route-guard configuration for Angular vs legacy bitstream routes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
40
to
44
| // Resolve angular bitstream download URLs | ||
| path: ':id/download', | ||
| component: BitstreamDownloadPageComponent, | ||
| resolve: { | ||
| bitstream: bitstreamPageResolver, |
Comment on lines
+1
to
+13
| import { BitstreamDownloadPageComponent } from './bitstream-download-page/bitstream-download-page.component'; | ||
| import { bitstreamPageResolver } from './bitstream-page.resolver'; | ||
| import { ROUTES } from './bitstream-page-routes'; | ||
| import { legacyBitstreamURLRedirectGuard } from './legacy-bitstream-url-redirect.guard'; | ||
|
|
||
| describe('bitstream page routes', () => { | ||
| it('should activate the Angular bitstream download page before redirecting to content', () => { | ||
| const downloadRoute = ROUTES.find((route) => route.path === ':id/download')!; | ||
|
|
||
| expect(downloadRoute).toBeDefined(); | ||
| expect(downloadRoute.component).toBe(BitstreamDownloadPageComponent); | ||
| expect(downloadRoute.resolve?.bitstream).toBe(bitstreamPageResolver); | ||
| expect(downloadRoute.canActivate).toBeUndefined(); |
Comment on lines
+16
to
+23
| it('should keep redirect guards on legacy bitstream URL routes', () => { | ||
| const legacyRoutes = ROUTES.filter((route) => route.path !== ':id/download' && route.component === BitstreamDownloadPageComponent); | ||
|
|
||
| expect(legacyRoutes.length).toBe(2); | ||
| legacyRoutes.forEach((route) => { | ||
| expect(route.canActivate).toContain(legacyBitstreamURLRedirectGuard); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References
Description
Fixes bitstream browser-back behavior by allowing the Angular bitstream download route to activate before redirecting to the actual bitstream content URL.
Instructions for Reviewers
List of changes in this PR:
bitstream-page-routes.ts.bitstream-page-routes.spec.tsverifying:Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.