Skip to content

Fix #4734: Normalize contextPath handling in bitstream download route - #4735

Closed
hernanhlagos wants to merge 2 commits into
DSpace:mainfrom
hernanhlagos:fix/fix-4734-contextpath-download-bitstream
Closed

Fix #4734: Normalize contextPath handling in bitstream download route#4735
hernanhlagos wants to merge 2 commits into
DSpace:mainfrom
hernanhlagos:fix/fix-4734-contextpath-download-bitstream

Conversation

@hernanhlagos

Copy link
Copy Markdown

References

Description

This PR fixes the generation of bitstream download URLs when DSpace Angular
is deployed under a custom context path (e.g. /repository).
Previously, the environment.ui.nameSpace was ignored, resulting in broken download links (404 Not Found).

Instructions for Reviewers

List of changes in this PR:

  • Normalize environment.ui.nameSpace before building the download route
  • Ensure / is omitted but custom paths (e.g. /repository) are correctly prepended
  • Prevent generation of double slashes in URLs

How to test

  1. Deploy DSpace Angular under a custom context path, e.g. http://localhost:4000/repository.
  2. As an administrator, edit an Item and go to the Edit Item screen.
  3. Select the Files tab.
  4. In the BUNDLE: ORIGINAL, TEXT, THUMBNAIL, LICENSE section, click the download icon in the Actions column.
  5. Observe the generated download URL:
    • Expected: http://localhost:4000/repository/bitstreams/<uuid>/download
    • Actual before fix: http://localhost:4000/bitstreams/<uuid>/download → results in 404 Not Found.
  6. Verify that download links now work correctly under both root (/) and subpath deployments.

Checklist

  • My PR is created against the main branch of code.
  • My PR is small in size and focused on a single fix.
  • My PR passes ESLint validation using npm run lint.
  • My PR doesn't introduce circular dependencies (npm run check-circ-deps).
  • My PR includes clear instructions for testing this fix.
  • This fix has been verified on DSpace Angular 7.4 and 9.1.

@hernanhlagos hernanhlagos changed the title Fix 4734: Normalize contextPath handling in bitstream download route Fix #4734: Normalize contextPath handling in bitstream download route Sep 26, 2025
@tdonohue tdonohue added bug 1 APPROVAL pull request only requires a single approval to merge port to dspace-7_x port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Sep 26, 2025
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Sep 26, 2025
@tdonohue

Copy link
Copy Markdown
Member

@hernanhlagos : Thanks for the PR! Just a note that this seems to be failing a few tests. It may just be that the tests require updates, not exactly sure. But, you should be able to see these failures locally if you run npm test

@github-actions

Copy link
Copy Markdown

Hi @hernanhlagos,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@lgeggleston lgeggleston added port to dspace-10_x This PR needs to be ported to `dspace-10_x` branch for next bug-fix release and removed port to dspace-7_x labels Jun 2, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 11.0 Release Jun 2, 2026
@hernanhlagos

Copy link
Copy Markdown
Author

After a delay on my side and after reviewing the current state of the branches, I found that this PR is now outdated against main.

When I originally opened it, the target branch was still aligned with the version where I reproduced the issue. Since then, the code has changed significantly in main, and this issue appears to be already resolved in dspace-10_x.

However, I have confirmed that the issue still persists in dspace-9_x. After comparing with dspace-10_x, I found that the correct fix for dspace-9_x is much smaller and should be submitted as a clean bugfix against that branch. In short, the fix is to use [routerLink] instead of [href] for the bitstream download button, so Angular resolves the link using the configured UI namespace / base href.

I'll close this PR and open a new one based directly on the current dspace-9_x branch, with the focused fix.

Thanks for reviewing the PR and sorry for the delay in following up.

@github-project-automation github-project-automation Bot moved this from 🙋 Needs Reviewers Assigned to ✅ Done in DSpace 11.0 Release Jun 12, 2026
4science-it pushed a commit to 4Science/dspace-angular that referenced this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug merge conflict port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release port to dspace-10_x This PR needs to be ported to `dspace-10_x` branch for next bug-fix release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bitstream download route fails when DSpace is deployed under a custom context path

4 participants